Fix bug in wrouter and routing DHCP packets

This commit is contained in:
Tim Young 2015-09-01 12:07:23 -05:00
parent 679d2f7010
commit efcfac9b1d
3 changed files with 40 additions and 28 deletions

View File

@ -379,8 +379,11 @@ namespace EduNetworkBuilder
NetworkLink nl;
if (NB.GetComponentType(tPacket.WhereAmI) != GeneralComponentType.device) return false; //we cannot do this.
NetworkDevice WhereFrom = (NetworkDevice)tPacket.WhereAmI;
switch (GetNicType)
NicType what = GetNicType;
if (!tPacket.isFresh && WhereFrom.IsWirelessForwarder() && what == NicType.wlan)
what = NicType.wport;
switch (what)
{
case NicType.lo:
case NicType.management_interface:

View File

@ -1222,6 +1222,7 @@ namespace EduNetworkBuilder
// if the dstIP matches (broadcast), we process it but it still continues
// Set the "we have processed it" flag
// and we process arrival
bool MacAddressMatch = HasMac(tPacket.destMAC);
bool ExactMatch = HasIPAddress(tPacket.destIP);
bool BroadcastMatch = HasBroadcastAddress(tPacket.destIP);
@ -1230,7 +1231,8 @@ namespace EduNetworkBuilder
if(ExactMatch || BroadcastMatch)
{
//Change this. Need a new ProcessArrival
ProcessArrival(tPacket);
if(tPacket.MyType != PacketType.dhcp_answer) //If it is a match, it should be handled elsewhere
ProcessArrival(tPacket);
if (ExactMatch && tPacket.isFinshed())
return;
}
@ -1321,8 +1323,11 @@ namespace EduNetworkBuilder
if ((tPacket.isFresh && !ExactMatch ) || (NeedsRouting && DoesRouting()) ||
IsWirelessForwarder())
{
if (nic == tPacket.InboundNic) break; //never send it out the nic it came in on
//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
string tMAC = tPacket.destMAC;
string ttMAC = tPacket.OutboundDestMAC;
if (BroadcastMatch && tPacket.MyType != PacketType.dhcp_answer)
tPacket.OutboundDestMAC = NB.BroadcastMACString;
tPacket.destMAC = tPacket.OutboundDestMAC;
@ -1330,6 +1335,8 @@ namespace EduNetworkBuilder
{
count++;
}
tPacket.destMAC = tMAC;
tPacket.OutboundDestMAC = ttMAC;
}
break;
case NicType.port:
@ -1626,6 +1633,8 @@ namespace EduNetworkBuilder
nPacket = new Packet(tPacket);
nPacket.isFresh = true; //So it starts from here
nPacket.Tracking = new PacketMessage();
if (hostname == "server0")
Console.WriteLine("here");
myNet.addPacket(nPacket);
//We need to find a dhcp IP for this.
IPAddress dst = RequestDHCPLease(tPacket.sourceMAC, tPacket.OutboundIP);

View File

@ -1,6 +1,6 @@
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Riched20 10.0.10240}\viewkind4\uc1
\pard\sa200\sl276\slmult1\f0\fs22\lang9 Version 1.0.22\par
\pard\sa200\sl276\slmult1\b\f0\fs22\lang9 Version 1.0.22\b0\par
* Added ssid and keys for wireless links\par
* Wireless will auto-disconnect if link is too long\par
* Wireless will auto-connect if ssid and key match, if link is short enough\par
@ -10,16 +10,16 @@
* wireless router handles dhcp requests properly (both responds to it but also passes it on)\par
* right-clicking light and microwave no longer has ping, arp, edit, and other context menus\par
* added net-test for DHCP server status (on/off)\par
* If multiple DHCP servers, client randomly chooses which to keep.\line Version 1.0.21 08/15/2015\par
* If multiple DHCP servers, client randomly chooses which to keep.\line\b Version 1.0.21 08/15/2015\b0\par
* Added a microwave and fluorescent light. They corrupt data when packets run close to them.\par
* Added some packet corruption puzzles\par
* Fixed window resize-on-load issue where the help window popped up first, then the builder window resized over to hide the help window. \par
Version 1.0.20 08/12/2015\par
\b Version 1.0.20 08/12/2015\b0\par
* wports do not display on tooltips or when printing the device info\par
* Added ctrl-s to quick-save a network we are working on\par
* commented out wireless devices for now - doing a big demo and wireless is not yet complete\par
* added search box to help\par
Version 1.0.19 08/08/2015\par
\b Version 1.0.19 08/08/2015\b0\par
*Updated context help for most puzzles that introduce new ideas.\par
* Sorted Help topics when adding them in net-tests.\par
* Added some images to the help to help clarify things.\par
@ -27,12 +27,12 @@ Version 1.0.19 08/08/2015\par
* Open Help so it can be kept open while the puzzles progress.\par
* Deal with minimized state better (used to shrink window to smallest possible state)\par
* Remember size and location of main window between uses.\par
Version 1.0.18 08/08/2015\par
\b Version 1.0.18 08/08/2015\b0\par
* Added Context Help for puzzles.\par
- Each puzzle can have context help\par
- There is a net-test to have us read help\par
* fixed minor problem with a "ding" sound when we load a puzzle that has something locked.\par
Version 1.0.17 08/01/2015\par
\b Version 1.0.17 08/01/2015\b0\par
* Added more help\par
* Much progress made in preparing for a French translation\par
* allow for Puzzle's description to be in another language\par
@ -41,21 +41,21 @@ Version 1.0.17 08/01/2015\par
* Save box starts in the directory of the file we opened (if we have one)\par
* Choose a language at startup if one has never been chosen, and have option to change language.\par
* Added another puzzle, showing what happens (or does not happen) if we have two networks that use the same IP addresses, and we want to build a VPN between them.\par
Version 1.0.16 07/18/2015\par
\b Version 1.0.16 07/18/2015\b0\par
* Added ability to break links (bad network wire)\par
* "connection lights" on network cards / ports when we edit devices\par
* Test for "needs link to" does not succeed if the link in question is a broken link\par
* Added a puzzle to show you how to find broken links \par
* Used broken links in other puzzles\par
* Fixed bug: switches could not use DHCP for many different reasons. Now it works for them.\par
Version 1.0.15 07/11/2015\par
\b Version 1.0.15 07/11/2015\b0\par
* Added ping time progress bar\par
* Fixed issue with things timing out before they completed. If the network screen is too large, it makes it go just a tiny bit slower and various things would fail. When the first packet successfully makes it to the far end, it recomputes the time needed and gives extra time.\par
* Added context menu ping. If an item is supposed to ping something, right-clicking adds the ping test to the menu. Takes some of the guess-work out of things.\par
* Fixed minor issue with this change log. Had two 1.0.11 versions & somehow was stating we were at version 10.x.x instead of 1.x.x (sigh) \par
* Fixed the VPNify puzzle. Had a goof in it.\par
* Made it so you cannot connect a link to a VPN. A VPN should be a virtual connection, not a physical connection.\par
Version 1.0.14 07/10/2015\par
\b Version 1.0.14 07/10/2015\b0\par
* When we finish a puzzle, allow us to auto-open the "next puzzle" box.\par
* Added lots more puzzles\par
* Added more help & documentation\par
@ -63,13 +63,13 @@ Version 1.0.14 07/10/2015\par
* Made it so the test for a matching route compared netmasks\par
* Added a printer object\par
* Added a copier object\par
Version 1.0.13 06/21/2015\par
\b Version 1.0.13 06/21/2015\b0\par
* Fixed issues with arp - arp could go through routers. Now works correctly\par
* Made it test for puzzle completion after adding devices\par
* Made it test for completion after changing / deleting devices\par
* Let you delete / add NICs on PCs, primarily so we can solve the duplicate MAC puzzle\par
* Replaced the "Network Loop" puzzle with the correct one.\par
Version 1.0.12 06/20/2015\par
\b Version 1.0.12 06/20/2015\b0\par
* Added VPN and TUN nic types\par
* Fixed numerous small bugs\par
* Fixed bug with early solution to failed ping test\par
@ -77,7 +77,7 @@ Version 1.0.12 06/20/2015\par
* Added a "firewall" network that has a firewall and vpns\par
* Added numerous firewall / vpn puzzles\par
* Fixed a DNS issue. It now more intelligently finds the right IP address when you ping it\par
Version 1.0.11 06/14/2015\par
\b Version 1.0.11 06/14/2015\b0\par
* Added the ability to lock various important features to make puzzles better\par
* Able to add interfaces (multiple IPs on a Network Card)\par
* Right-click context menu to add net-tests. \par
@ -85,7 +85,7 @@ Version 1.0.11 06/14/2015\par
* Can add NICs (on some devices)\par
* Can delete NICs\par
* Fixed minor bug with broadcast pinging solving ping test for individual computers\par
Version 1.0.10 06/13/2015\par
\b Version 1.0.10 06/13/2015\b0\par
* Renamed puzzles to manage them easier\par
* Deal with duplicate IPs, and what happens when a packet returns to a computer that did not send it.\par
* Change to the help window so you can keep the window open while working with the puzzle.\par
@ -95,7 +95,7 @@ Version 1.0.10 06/13/2015\par
* Added a FailedPing test so we can ping things that must fail (show the firewall works)\par
* added more to the help\par
* added more puzzles\par
Version 1.0.0.9 05/29/2015\par
\b Version 1.0.0.9 05/29/2015\b0\par
* Add a grid to the network map. It makes things easier to straighten up\par
* Sorted and organized the puzzles\par
* Made a level for each puzzle.\par
@ -105,41 +105,41 @@ Version 1.0.0.9 05/29/2015\par
* Reset buttons when we load a new network.\par
* Added a bunch more puzzles\par
* Sometimes the remembered IP gets annoying when it remembers odd gateways and numbers we cannot change. Fixed that in many cases.\par
Version 1.0.0.8 05/25/2015\par
\b Version 1.0.0.8 05/25/2015\b0\par
* Always Start with level0 puzzles for now\par
* Fixed the icon when program running\par
* Added an infrastructure for Puzzles (needs work)\par
* Added a number of basic puzzles\par
* Fixed DHCP Leases. Now it clears leases when you change the DHCP server range.\par
Version 1.0.0.7 05/16/2015\par
\b Version 1.0.0.7 05/16/2015\b0\par
* Added file association so we can double-click an enbx file\par
* Fixed the icon so it looks right (removed left edge)\par
Version 1.0.0.6 05/16/2015\par
\b Version 1.0.0.6 05/16/2015\b0\par
* Able to delete a route (right click route and delete it)\par
* Add map title as something we can load/save\par
* Add message as something we can load and save\par
* Changing size of items affects all items\par
* Allow entering a hostname in the IP address field (ping / gateway)\par
Version 1.0.0.5 04/26/2015\par
\b Version 1.0.0.5 04/26/2015\b0\par
* Fixed ping from switch\par
* Fixed error message when pinging IP that does not exist\par
Version 1.0.0.4 04/26/2015\par
\b Version 1.0.0.4 04/26/2015\b0\par
* Fixed broadcast ping\par
*Fixed dhcp request error\par
Version 1.0.0.3 04/15/2015\par
* Added "file" -> "new" to erase and start a clean new network\par
\b Version 1.0.0.3 04/15/2015\par
\b0 * Added "file" -> "new" to erase and start a clean new network\par
* Fixed pc2 to have gateway on "solved"->"Two Networks"\par
* Fixed - only machines capable of doing DHCP do dhcp request if we do DHCP request on all\par
* Changed - major overhaul to tcp-stack.\par
* Downgrade - Arp temporarily removed from system while tcp-stack overhaul completed\par
Version 1.0.0.2 4/19/2015\par
\b Version 1.0.0.2 4/19/2015\b0\par
* Added IP-Phone\par
* Packets terminate at the far end - this makes it easier to see packets go both directions\par
* Packets are randomized in transit - Allows packets to arrive at slightly different times\par
Version 1.0.0.1 4/11/2015\par
\b Version 1.0.0.1 4/11/2015\b0\par
* DHCP selection on nics is not functioning correctly\par
* Various small bug-fixes\par
Version 1.0.0.0 4/10/2015\par
\b Version 1.0.0.0 4/10/2015\b0\par
This is the initial alpha build\par
* basic pinging\par
* basic arp\par