DHCPD: Fix calculation of lease address. Bad logic causes repeated assignment of the same IP address. SourceForge bug #21 from Paolo Messina.

This commit is contained in:
Gregory Nutt 2013-09-06 08:10:54 -06:00
parent 9fd96da125
commit 09f534db73
2 changed files with 5 additions and 3 deletions

View File

@ -626,4 +626,6 @@
* apps/examples/usbmsc: apps/examples/usbstorage renamed usbmsc.
Change submitted by CCTSAO (2013-6-5).
* apps/examples/pwm: Clean-up some configuration confusion (2013-9-5).
* apps/netutils/dhcpd/dhcpd.c: Fix calculation of the next lease
address. SourceForge bug #21 from Paolo Messina (2013-9-6).

View File

@ -1,7 +1,7 @@
/****************************************************************************
* netutils/dhcpd/dhcpd.c
*
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -363,11 +363,11 @@ struct lease_s *dhcpd_setlease(const uint8_t *mac, in_addr_t ipaddr, time_t expi
* Name: dhcp_leaseipaddr
****************************************************************************/
static inline in_addr_t dhcp_leaseipaddr( struct lease_s *lease)
static inline in_addr_t dhcp_leaseipaddr(struct lease_s *lease)
{
/* Return IP address in host order */
return (g_state.ds_leases - lease)/sizeof(struct lease_s) + CONFIG_NETUTILS_DHCPD_STARTIP;
return (in_addr_t)(lease - g_state.ds_leases) + CONFIG_NETUTILS_DHCPD_STARTIP;
}
/****************************************************************************