diff options
Diffstat (limited to 'networking/udhcp/leases.c')
-rw-r--r-- | networking/udhcp/leases.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c index f511340..2f7847d 100644 --- a/networking/udhcp/leases.c +++ b/networking/udhcp/leases.c @@ -4,20 +4,8 @@ * Russ Dill <Russ.Dill@asu.edu> July 2001 */ -#include <time.h> -#include <string.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -#include "dhcpd.h" -#include "files.h" -#include "options.h" -#include "leases.h" -#include "arpping.h" #include "common.h" - -#include "static_leases.h" +#include "dhcpd.h" uint8_t blank_chaddr[] = {[0 ... 15] = 0}; @@ -138,22 +126,20 @@ uint32_t find_address(int check_expired) if ((addr & 0xFF) == 0xFF) continue; /* Only do if it isn't an assigned as a static lease */ - if(!reservedIp(server_config.static_leases, htonl(addr))) - { - - /* lease is not taken */ - ret = htonl(addr); - if ((!(lease = find_lease_by_yiaddr(ret)) || - - /* or it expired and we are checking for expired leases */ - (check_expired && lease_expired(lease))) && - - /* and it isn't on the network */ - !check_ip(ret)) { - return ret; - break; + if (!reservedIp(server_config.static_leases, htonl(addr))) { + + /* lease is not taken */ + ret = htonl(addr); + lease = find_lease_by_yiaddr(ret); + + /* no lease or it expired and we are checking for expired leases */ + if ( (!lease || (check_expired && lease_expired(lease))) + && /* and it isn't on the network */ !check_ip(ret) + ) { + return ret; + break; + } } } - } return 0; } |