From 33e9a61efd57f11e6092d683f03592c613a70cb4 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sun, 9 Aug 2015 16:33:00 -0600 Subject: [PATCH] wports working as switches, wport not printing and not in toltips --- EduNetworkBuilder/LinkEditor.cs | 2 ++ EduNetworkBuilder/NetworkCard.cs | 4 ++- EduNetworkBuilder/NetworkDevice.cs | 36 +++++++++++++++---- EduNetworkBuilder/NetworkLink.cs | 6 ++++ EduNetworkBuilder/Resources/ReleaseNotes.rtf | Bin 7917 -> 8011 bytes 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/EduNetworkBuilder/LinkEditor.cs b/EduNetworkBuilder/LinkEditor.cs index d29d11e..3b0bf76 100644 --- a/EduNetworkBuilder/LinkEditor.cs +++ b/EduNetworkBuilder/LinkEditor.cs @@ -203,6 +203,8 @@ namespace EduNetworkBuilder int dNicIndex = lbDstNic.SelectedIndex; NetworkCard dNic = Dst.NicFromName(lbDstNic.SelectedItem.ToString()); LinkType LT = NB.ParseEnum(cbLinkType.SelectedItem.ToString()); + if (sNic.GetNicType == NicType.wport || sNic.GetNicType == NicType.wlan) + LT = LinkType.wireless; //We cannot have broken wireless links the same way. NetworkLink newLink = new NetworkLink(sNic.myID, dNic.myID, LT); Net.AddItem(newLink); Close(); diff --git a/EduNetworkBuilder/NetworkCard.cs b/EduNetworkBuilder/NetworkCard.cs index 3e29c66..c9ab84e 100644 --- a/EduNetworkBuilder/NetworkCard.cs +++ b/EduNetworkBuilder/NetworkCard.cs @@ -348,6 +348,7 @@ namespace EduNetworkBuilder case NicType.none: break; //Do nothing case NicType.eth: + case NicType.wlan: //see if it the packet dest is local to this nic foreach (NetworkInterface nf in interfaces.ToList()) { @@ -472,6 +473,7 @@ namespace EduNetworkBuilder } break; case NicType.port: + case NicType.wport: nPacket = new Packet(tPacket); if (HasBroadcastAddresses(tPacket.destIP)) { @@ -522,7 +524,7 @@ namespace EduNetworkBuilder Network mynet; NetworkDevice nd; //We make sure the MAC matches. - if (myNicType == NicType.port) + if (myNicType == NicType.port || myNicType == NicType.wport) { //Try tracking the arp if we can mynet = NB.GetNetwork(); diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index 7ba48c0..825b41a 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -386,6 +386,8 @@ namespace EduNetworkBuilder //Add IP Addresses that are assigned foreach (NetworkCard nic in NICs) { + if (nic.GetNicType == NicType.wport || nic.GetNicType == NicType.port) + continue; foreach(string addr in nic.IPAddresses()) { answer += "\n" + addr; @@ -755,7 +757,7 @@ namespace EduNetworkBuilder foreach (NetworkCard nic in NICs) { - if(nic.GetNicType != NicType.lo && nic.GetNicType != NicType.port) + if(nic.GetNicType != NicType.lo && nic.GetNicType != NicType.port && nic.GetNicType != NicType.wport) { string title = ""; if (nic.GetNicType == NicType.management_interface) @@ -888,6 +890,9 @@ namespace EduNetworkBuilder if (myType == NetworkComponentType.net_hub) return true; if (myType == NetworkComponentType.net_switch) return true; if (myType == NetworkComponentType.wap) return true; + if (myType == NetworkComponentType.wbridge) return true; + if (myType == NetworkComponentType.wrepeater) return true; + if (myType == NetworkComponentType.wrouter) return true; return false; } @@ -1130,8 +1135,6 @@ namespace EduNetworkBuilder } } } - if (myType == NetworkComponentType.net_hub || myType == NetworkComponentType.wap) - dNic = null; //Hubs/WAPs never know the dnic. They still need the sNic, however //Delivery //Loop through all nics (skip the interface) it came in on @@ -1156,6 +1159,7 @@ namespace EduNetworkBuilder case NicType.tun: case NicType.vpn: case NicType.wan: + 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())) @@ -1172,14 +1176,29 @@ namespace EduNetworkBuilder } break; case NicType.port: - if(!ExactMatch && !MacAddressMatch) + case NicType.wport: + NetworkCard tdNic = dNic; + if (myType == NetworkComponentType.wrouter) + { + //On wRouters, the wPorts are hubs, but the ports are switches + if (dNic != null && dNic.GetNicType == NicType.wport && nic.GetNicType == NicType.wport) + tdNic = null; + } + else + { + if (nic.GetNicType == NicType.port && myType == NetworkComponentType.net_hub) + tdNic = null; //Hubs/WAPs never know the dnic. They still need the sNic, however + if (nic.GetNicType == NicType.wport) + tdNic = null; //Hubs/WAPs never know the dnic. They still need the sNic, however + } + if (!ExactMatch && !MacAddressMatch) { //If the packet does not terminate here, and we are not routing it to here... //Pass it to the port. The port duplicates it and sends it out //Do not send it out the port it came in on (sNic) //If we know the dNic, only send it out that //But if we do not know a dnic, send it out all of them (except the sNic) - if (sNic != nic && (dNic == null || (dNic != null && dNic.ConnectedLink == -1) || dNic == nic)) + if (sNic != nic && (tdNic == null || (tdNic != null && tdNic.ConnectedLink == -1) || tdNic == nic)) { if (nic.SendPacketOutNIC(tPacket)) { @@ -1944,7 +1963,9 @@ namespace EduNetworkBuilder return; } } - if(nf == null && myType != NetworkComponentType.net_switch && myType != NetworkComponentType.net_hub) + if(nf == null && myType != NetworkComponentType.net_switch && myType != NetworkComponentType.net_hub && + myType != NetworkComponentType.wbridge && myType != NetworkComponentType.wrepeater && + myType != NetworkComponentType.wrouter) { tPacket.AddMessage(DebugLevel.debug, hostname + " The device had no local IPs. Quietly dropped."); tPacket.Tracking.Status = hostname + " Failed: no IPs local to the packet."; @@ -1970,6 +1991,8 @@ namespace EduNetworkBuilder if (myType == NetworkComponentType.net_hub) return true; 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; return false; } /// @@ -1980,6 +2003,7 @@ namespace EduNetworkBuilder { if (myType == NetworkComponentType.router) return true; if (myType == NetworkComponentType.firewall) return true; + if (myType == NetworkComponentType.wrouter) return true; return false; } diff --git a/EduNetworkBuilder/NetworkLink.cs b/EduNetworkBuilder/NetworkLink.cs index f326c84..a1791ca 100644 --- a/EduNetworkBuilder/NetworkLink.cs +++ b/EduNetworkBuilder/NetworkLink.cs @@ -139,6 +139,12 @@ namespace EduNetworkBuilder Point sPoint = Src.GetCenter(); Point dPoint = Dst.GetCenter(); Pen tPen = new Pen(Color.Black, 4); + if(theLinkType == LinkType.wireless) + { + //tPen = new Pen(Color.DarkSlateGray); + tPen.DashCap = System.Drawing.Drawing2D.DashCap.Round; + tPen.DashPattern = new float[] { 8.0F, 2.0F}; + } Graphics.FromImage(BaseImage).DrawLine(tPen,sPoint,dPoint); IsDirty = false; //we have printed, we are no longer dirty. } diff --git a/EduNetworkBuilder/Resources/ReleaseNotes.rtf b/EduNetworkBuilder/Resources/ReleaseNotes.rtf index ddc393ec9d12a7cc4b67b569202725af64552bd9..b27a9053e39b6d635605e80022fb3b8066b9c762 100644 GIT binary patch delta 93 zcmaEBd)jWop&%oJn1aM2UM?+#@`C)Ll46CFe1*LH5`~n^;)0ySN`?G9g_8XIoRZ9f tVuk!7h4PHlJcWXy%)FA!ymW<