diff options
author | Anjali Nijhara <a.nijhara@samsung.com> | 2023-12-22 10:46:50 +0530 |
---|---|---|
committer | Anjali Nijhara <a.nijhara@samsung.com> | 2023-12-22 10:46:50 +0530 |
commit | 1be0c756c3a52e7b120da3e50be579d8e92ad5ac (patch) | |
tree | 23c4f30580449cf51f4e40bf2e9339b80f504a04 | |
parent | 755acc1798caff3a7c1557157a88c878111e9427 (diff) | |
download | toybox-1be0c756c3a52e7b120da3e50be579d8e92ad5ac.tar.gz toybox-1be0c756c3a52e7b120da3e50be579d8e92ad5ac.tar.bz2 toybox-1be0c756c3a52e7b120da3e50be579d8e92ad5ac.zip |
Reset timeval to default value when tv_sec parameter become invalid.
Change-Id: I43fe8f9c252734aecb73a85776030d09ac51684b
-rw-r--r-- | toys/pending/dhcpd.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/toys/pending/dhcpd.c b/toys/pending/dhcpd.c index 0a3a2c5..3bac14d 100644 --- a/toys/pending/dhcpd.c +++ b/toys/pending/dhcpd.c @@ -1707,6 +1707,13 @@ void dhcpd_main(void) int maxfd = (sigfd.rd > gstate.listensock)? sigfd.rd : gstate.listensock; dbg("select waiting ....\n"); + if (tv.tv_sec < 0) { + dbg("timestmp: %u waited: %u tv_sec: %u, reset tv_sec to default value\n", timestmp, waited, tv.tv_sec); + waited = 0; + tv.tv_sec = gconfig.auto_time - waited; + tv.tv_usec = 0; + } + retval = select(maxfd + 1, &rfds, NULL, NULL, (gconfig.auto_time?&tv:NULL)); if (retval < 0) { if (errno == EINTR) { @@ -2035,6 +2042,7 @@ void dhcpd_main(void) msgtype = DHCPNAK; optptr = set_optval(optptr, DHCP_OPT_MESSAGE_TYPE, &msgtype, 1); send_packet(1); + dbg("Send Message Type : DHCPNAK\n"); break; } get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options, @@ -2045,6 +2053,7 @@ void dhcpd_main(void) optptr = set_optval(optptr, DHCP_OPT_LEASE_TIME, &reqested_lease, 4); optptr = set_reqparam(optptr, gstate.rqopt); send_packet(1); + dbg("Send Message Type : DHCPOFFER\n"); break; case DHCPREQUEST: msgtype = DHCPACK; @@ -2063,6 +2072,7 @@ void dhcpd_main(void) msgtype = DHCPNAK; optptr = set_optval(optptr, DHCP_OPT_MESSAGE_TYPE, &msgtype, 1); send_packet(1); + dbg("Send Message Type : DHCPNAK\n"); break; } get_reqparam(&gstate.rqopt); @@ -2072,6 +2082,7 @@ void dhcpd_main(void) optptr = set_optval(optptr, DHCP_OPT_LEASE_TIME, &reqested_lease, 4); optptr = set_reqparam(optptr, gstate.rqopt); send_packet(1); + dbg("Send Message Type : DHCPACK\n"); write_leasefile(); break; case DHCPDECLINE:// FALL THROUGH |