From 211fa6f2bb0aa377476d00995b2637d310c4cb54 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sun, 6 Sep 2015 13:59:41 -0500 Subject: [PATCH] Fixed issue where we need to go out same nic as we came in on (but different interface) --- EduNetworkBuilder/NetworkCard.cs | 5 +++++ EduNetworkBuilder/NetworkDevice.cs | 4 ++-- EduNetworkBuilder/NetworkInterface.cs | 5 ++++- EduNetworkBuilder/Packet.cs | 2 ++ EduNetworkBuilder/Resources/ReleaseNotes.rtf | 4 +++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/EduNetworkBuilder/NetworkCard.cs b/EduNetworkBuilder/NetworkCard.cs index ba1cc36..59d2be5 100644 --- a/EduNetworkBuilder/NetworkCard.cs +++ b/EduNetworkBuilder/NetworkCard.cs @@ -392,8 +392,13 @@ namespace EduNetworkBuilder case NicType.eth: case NicType.wlan: //see if it the packet dest is local to this nic + if (WhereFrom.hostname == "router0") + Console.WriteLine("wearehere"); foreach (NetworkInterface nf in interfaces.ToList()) { + if (tPacket.InboundNic != null && tPacket.InboundNic == this && + tPacket.InboundInterface != null && tPacket.InboundInterface == nf) + continue; //skip sending it out this interface if it came in this interface. 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 diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index a0fbfae..0924308 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -1366,7 +1366,7 @@ namespace EduNetworkBuilder if ((tPacket.isFresh && !ExactMatch ) || (NeedsRouting && DoesRouting()) || IsWirelessForwarder()) { - if (nic == tPacket.InboundNic) break; //never send it out the nic it came in on + // if (nic == tPacket.InboundNic) break; //this case is dealt with in nic.SendPacketOutNic //Pass it to the NIC to send out each nic+interface. //The nic checks to see if it works and then processes it string tMAC = tPacket.destMAC; @@ -2161,7 +2161,7 @@ namespace EduNetworkBuilder ProcessArrival(tPacket); return; } - NetworkInterface nf = nc.LocalInterface(tPacket.destIP, tPacket.Tracking); + NetworkInterface nf = nc.LocalInterface(tPacket.sourceIP, tPacket.Tracking); if(nf == null) { nf = nc.LocalInterface(tPacket.TsourceIP, tPacket.Tracking); diff --git a/EduNetworkBuilder/NetworkInterface.cs b/EduNetworkBuilder/NetworkInterface.cs index 71ecc19..41932d6 100644 --- a/EduNetworkBuilder/NetworkInterface.cs +++ b/EduNetworkBuilder/NetworkInterface.cs @@ -100,6 +100,7 @@ namespace EduNetworkBuilder /// public void ProcessOutboundPacket(Packet tPacket) { + tPacket.InboundInterface = null; //forget the interface we had come in on now that we are leaving. if (tPacket.sourceIP == null || tPacket.sourceIP.GetIP.ToIpString() == NB.ZeroIPString) { //This happens if we are starting a new packet. We should also do this if we are masquerading. @@ -112,7 +113,9 @@ namespace EduNetworkBuilder bool isgood = false; if (tPacket.destIP != null && tPacket.destIP.GetIP == myIP.GetIP) isgood = true; if (tPacket.destIP != null && myIP.IsLocal(tPacket.destIP)) isgood = true; - if (myIP.NetworkAddress == myIP.GetIP) isgood = true; + if (myIP.NetworkAddress == myIP.GetIP) isgood = true; + + tPacket.InboundInterface = this; if(isgood) { diff --git a/EduNetworkBuilder/Packet.cs b/EduNetworkBuilder/Packet.cs index fc9c882..3d71161 100644 --- a/EduNetworkBuilder/Packet.cs +++ b/EduNetworkBuilder/Packet.cs @@ -56,6 +56,7 @@ namespace EduNetworkBuilder DateTime StartTime = DateTime.Now; public NetworkCard OutboundNic = null; public NetworkCard InboundNic = null; + public NetworkInterface InboundInterface = null; public NetworkInterface OutboundIF = null; public IPAddress OutboundIP = new IPAddress(NB.ZeroIPString); public string OutboundMAC = ""; @@ -326,6 +327,7 @@ namespace EduNetworkBuilder { if (theLink == null) return; InboundNic = null; + InboundInterface = null; WhereAmI = theLink; MyStatus = PacketStatus.moving; myLinkPercent = 0; diff --git a/EduNetworkBuilder/Resources/ReleaseNotes.rtf b/EduNetworkBuilder/Resources/ReleaseNotes.rtf index ff3cfd8..40785d9 100644 --- a/EduNetworkBuilder/Resources/ReleaseNotes.rtf +++ b/EduNetworkBuilder/Resources/ReleaseNotes.rtf @@ -1,7 +1,9 @@ {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}} {\*\generator Riched20 10.0.10240}\viewkind4\uc1 \pard\sa200\sl276\slmult1\b\f0\fs22\lang9 Version 1.0.23 \par -\b0 * Fixed issues with broadcast packets\b\par +\b0 * Fixed issues with broadcast packets\par +* Fixed a network loop issue\par +* Fixed issue with multiple interfaces and being able to go out a different interface than we came in on\b\par Version 1.0.22 09/01/2015\b0\par * Added ssid and keys for wireless links\par * Wireless will auto-disconnect if link is too long\par