rt_names: stop allocating 5k in rwdata
[oweals/busybox.git] / networking / udhcp / leases.c
index f5113408b73ff87f9eaeebeebff6c1508b68e4df..2f7847d74f52b89414856c8e92e8112cd9dd3e4e 100644 (file)
@@ -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;
 }