diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-09-06 08:10:54 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-09-06 08:10:54 -0600 |
commit | e93f724725d6fcab54560cba0972ff56ce3c4619 (patch) | |
tree | f606a002a035902e52b0b6a74961f01418264763 /apps/netutils | |
parent | ee4c5214f959943c196dbeaaab9ed038f4dbd0f1 (diff) | |
download | nuttx-e93f724725d6fcab54560cba0972ff56ce3c4619.tar.gz nuttx-e93f724725d6fcab54560cba0972ff56ce3c4619.tar.bz2 nuttx-e93f724725d6fcab54560cba0972ff56ce3c4619.zip |
DHCPD: Fix calculation of lease address. Bad logic causes repeated assignment of the same IP address. SourceForge bug #21 from Paolo Messina.
Diffstat (limited to 'apps/netutils')
-rw-r--r-- | apps/netutils/dhcpd/dhcpd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/apps/netutils/dhcpd/dhcpd.c b/apps/netutils/dhcpd/dhcpd.c index d9143288d..ce11ee248 100644 --- a/apps/netutils/dhcpd/dhcpd.c +++ b/apps/netutils/dhcpd/dhcpd.c @@ -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; } /**************************************************************************** |