summaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-07-01 17:05:57 +0000
committerDenis Vlasenko2007-07-01 17:05:57 +0000
commitc82b5108e1a40f3b299043770e01d7d7db35de04 (patch)
tree35039a36868df644b8e5ffc766c1b0c921c88ab5 /networking/udhcp/dhcpd.c
parentdc7a5eae36d31f5cfc301de2499329b8a03ea660 (diff)
downloadbusybox-c82b5108e1a40f3b299043770e01d7d7db35de04.zip
busybox-c82b5108e1a40f3b299043770e01d7d7db35de04.tar.gz
udhcp: new config option "Rewrite the lease file at every new acknowledge"
(Mats Erik Andersson <mats@blue2net.com> (Blue2Net AB)) udhcp: consistently treat server_config.start/end IPs as host-order fix IP parsing for 64bit machines fix unsafe hton macro usage in read_opt() do not chdir("/") when daemonizing fix help text
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 778121b..6be3c0e 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -37,7 +37,7 @@ int udhcpd_main(int argc, char **argv)
//Huh, dhcpd don't have --foreground, --syslog options?? TODO
if (!ENABLE_FEATURE_UDHCP_DEBUG) {
- bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);
+ bb_daemonize_or_rexec(0, argv);
logmode &= ~LOGMODE_STDIO;
}
@@ -60,15 +60,15 @@ int udhcpd_main(int argc, char **argv)
}
/* Sanity check */
- num_ips = ntohl(server_config.end) - ntohl(server_config.start) + 1;
+ num_ips = server_config.end_ip - server_config.start_ip + 1;
if (server_config.max_leases > num_ips) {
- bb_error_msg("max_leases value (%lu) not sane, "
- "setting to %lu instead",
+ bb_error_msg("max_leases=%lu is too big, "
+ "setting to %lu",
server_config.max_leases, num_ips);
server_config.max_leases = num_ips;
}
- leases = xzalloc(server_config.max_leases * sizeof(struct dhcpOfferedAddr));
+ leases = xzalloc(server_config.max_leases * sizeof(*leases));
read_leases(server_config.lease_file);
if (read_interface(server_config.interface, &server_config.ifindex,
@@ -207,10 +207,13 @@ int udhcpd_main(int argc, char **argv)
/* make some contention for this address */
} else
sendNAK(&packet);
- } else if (requested_align < server_config.start
- || requested_align > server_config.end
- ) {
- sendNAK(&packet);
+ } else {
+ uint32_t r = ntohl(requested_align);
+ if (r < server_config.start_ip
+ || r > server_config.end_ip
+ ) {
+ sendNAK(&packet);
+ }
} /* else remain silent */
} else {