mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
Merge pull request #417 from DrDoof/fix/dhcp-missing-t1
dhcp: renew at half the lease when the server omits T1
This commit is contained in:
1 file changed
+12
@@ -332,6 +332,18 @@ void parse_dhcp(void)
|
|||||||
uip_ipaddr(&uip_hostaddr, dhcp_state.current_ip[0], dhcp_state.current_ip[1], dhcp_state.current_ip[2], dhcp_state.current_ip[3]);
|
uip_ipaddr(&uip_hostaddr, dhcp_state.current_ip[0], dhcp_state.current_ip[1], dhcp_state.current_ip[2], dhcp_state.current_ip[3]);
|
||||||
uip_ipaddr(&uip_draddr, dhcp_state.router[0], dhcp_state.router[1], dhcp_state.router[2], dhcp_state.router[3]);
|
uip_ipaddr(&uip_draddr, dhcp_state.router[0], dhcp_state.router[1], dhcp_state.router[2], dhcp_state.router[3]);
|
||||||
uip_ipaddr(&uip_netmask, dhcp_state.subnet[0], dhcp_state.subnet[1], dhcp_state.subnet[2], dhcp_state.subnet[3]);
|
uip_ipaddr(&uip_netmask, dhcp_state.subnet[0], dhcp_state.subnet[1], dhcp_state.subnet[2], dhcp_state.subnet[3]);
|
||||||
|
/* T1 is optional. Without it the renewal time stays zero, which
|
||||||
|
* makes dhcp_timer zero, and the callback then sends a REQUEST on
|
||||||
|
* every pass through LEASING: client and server trade REQUEST and
|
||||||
|
* ACK as fast as the round trip allows. RFC 2131 has the client
|
||||||
|
* renew at half the lease when the server does not say, and if
|
||||||
|
* there is no lease either, pick something rather than zero. Only
|
||||||
|
* filled in when absent, so a server that asks for a short renewal
|
||||||
|
* still gets it. */
|
||||||
|
if (!dhcp_state.renewal)
|
||||||
|
dhcp_state.renewal = dhcp_state.lease / 2;
|
||||||
|
if (!dhcp_state.renewal)
|
||||||
|
dhcp_state.renewal = 60;
|
||||||
dhcp_state.state = DHCP_LEASING;
|
dhcp_state.state = DHCP_LEASING;
|
||||||
dhcp_state.ticks = SYS_TICK_HZ;
|
dhcp_state.ticks = SYS_TICK_HZ;
|
||||||
dhcp_state.dhcp_timer = dhcp_state.renewal > 0xffff ? 0xffff : dhcp_state.renewal;
|
dhcp_state.dhcp_timer = dhcp_state.renewal > 0xffff ? 0xffff : dhcp_state.renewal;
|
||||||
|
|||||||
Reference in new issue
Block a user