Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Revision 179:55342264fca1, committed 2020-12-30
- Comitter:
- andrewboyson
- Date:
- Wed Dec 30 19:26:19 2020 +0000
- Parent:
- 178:52714fef5ca1
- Child:
- 180:0a30cff6b36a
- Commit message:
- DHCP did not adequately handle the NAKs that my Sky router was handing out. Now correctly tears down the IPv4 DHCP information and starts afresh.
Changed in this revision
| udp/dhcp/dhcp.c | Show annotated file Show diff for this revision Revisions of this file |
--- a/udp/dhcp/dhcp.c Tue Dec 29 19:14:35 2020 +0000
+++ b/udp/dhcp/dhcp.c Wed Dec 30 19:26:19 2020 +0000
@@ -58,6 +58,22 @@
char DhcpDomainName[DNS_MAX_LABEL_LENGTH+1];
char DhcpHostName [DNS_MAX_LABEL_LENGTH+1];
+static void clearAll()
+{
+ DhcpLeaseTime = 0;
+ DhcpServerIp = 0;
+ DhcpRouterIp = 0;
+ DhcpSubnetMask = 0;
+ DhcpNtpIp = 0;
+ DhcpRenewalT1 = 0;
+ DhcpRenewalT2 = 0;
+ DhcpBroadcastIp = 0;
+ DhcpLocalIp = 0;
+ DhcpDnsServerIp = 0;
+ DhcpDomainName[0] = 0;
+ DhcpHostName [0] = 0;
+}
+
bool DhcpIpNeedsToBeRouted(uint32_t ip)
{
if ((ip & 0x000000FF) == 0xFF) return false; //Broadcast 255.xxx.xxx.xxx
@@ -267,6 +283,7 @@
break;
case DHCPNAK:
if (DhcpTrace) { LogTime("DHCP <- nack ip "); Ip4AddressLog(yiaddr); Log("\r\n"); }
+ clearAll();
break;
default:
LogTimeF("DHCP <- unknown message %d\r\n", dhcpMessageType);
@@ -300,8 +317,7 @@
else
{
if (DhcpTrace) LogTimeF("DHCP lease has expired\r\n");
- DhcpLocalIp = 0;
- DhcpServerIp = 0;
+ clearAll();
*pSize = sendRequest(pPacket, DHCPDISCOVER, 0, 0); //If outside T2 then start from scratch to do a full DHCP
dest = BROADCAST;
}