From 27d3b880836656643ae2982da76fcdda4dd86687 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Thu, 5 Oct 2017 11:06:59 -0500 Subject: [PATCH] Fix a dhcp bug with WirelessRouters. Needed better wisdom for returning the appropriate gateway in different modes. --- EduNetworkBuilder/NetworkDevice.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index 6cc5adc..e912b6b 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -2977,7 +2977,26 @@ namespace EduNetworkBuilder public IPAddress LookupDHCPLease(string MAC, IPAddress NIC_IP) { IPAddress gateway; - if (myType != NetworkComponentType.firewall) + NetworkComponentType NCT = myType; + if(myType == NetworkComponentType.wrouter) + { + //If we are a wireless router, we could be set up as an access point, or as a router/firewall + //If the default gateway is on the LAN, we use the gateway. If the default gateway is on the WAN, + //We use the IP of the firewall IP. (NIC_IP) + IPAddress tGateway = GetGateway(); + NetworkCard lNic = LocalNic(tGateway); + if(lNic != null && lNic.GetNicType == NicType.wan) + { + //The gateway is on the WAN. We will give it our own IP as if we are a firewall + NCT = NetworkComponentType.firewall; + } + else + { + //The gateway is on the LAN. We pretend we are an Access Point. + NCT = NetworkComponentType.wap; + } + } + if (NCT != NetworkComponentType.firewall) { gateway = GetGateway(); }