aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index a1a7f6b57..4b3ed240c 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -28,6 +28,7 @@
//usage: "\n -f Run in foreground"
//usage: "\n -S Log to syslog too"
//usage: "\n -I ADDR Local address"
+//usage: "\n -a MSEC Timeout for ARP ping (default 2000)"
//usage: IF_FEATURE_UDHCP_PORT(
//usage: "\n -P N Use port N (default 67)"
//usage: )
@@ -148,7 +149,8 @@ static uint32_t select_lease_time(struct dhcp_packet *packet)
static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
uint32_t static_lease_nip,
struct dyn_lease *lease,
- uint8_t *requested_ip_opt)
+ uint8_t *requested_ip_opt,
+ unsigned arpping_ms)
{
struct dhcp_packet packet;
uint32_t lease_time_sec;
@@ -187,7 +189,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
}
else {
/* Otherwise, find a free IP */
- packet.yiaddr = find_free_or_expired_nip(oldpacket->chaddr);
+ packet.yiaddr = find_free_or_expired_nip(oldpacket->chaddr, arpping_ms);
}
if (!packet.yiaddr) {
@@ -304,6 +306,8 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
unsigned opt;
struct option_set *option;
char *str_I = str_I;
+ const char *str_a = "2000";
+ unsigned arpping_ms;
IF_FEATURE_UDHCP_PORT(char *str_P;)
#if ENABLE_FEATURE_UDHCP_PORT
@@ -314,9 +318,10 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
opt_complementary = "vv";
#endif
- opt = getopt32(argv, "fSI:v"
+ opt = getopt32(argv, "fSI:va:"
IF_FEATURE_UDHCP_PORT("P:")
, &str_I
+ , &str_a
IF_FEATURE_UDHCP_PORT(, &str_P)
IF_UDHCP_VERBOSE(, &dhcp_verbose)
);
@@ -336,11 +341,13 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
free(lsa);
}
#if ENABLE_FEATURE_UDHCP_PORT
- if (opt & 16) { /* -P */
+ if (opt & 32) { /* -P */
SERVER_PORT = xatou16(str_P);
CLIENT_PORT = SERVER_PORT + 1;
}
#endif
+ arpping_ms = xatou(str_a);
+
/* Would rather not do read_config before daemonization -
* otherwise NOMMU machines will parse config twice */
read_config(argv[0] ? argv[0] : DHCPD_CONF_FILE);
@@ -498,7 +505,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
case DHCPDISCOVER:
log1("Received DISCOVER");
- send_offer(&packet, static_lease_nip, lease, requested_ip_opt);
+ send_offer(&packet, static_lease_nip, lease, requested_ip_opt, arpping_ms);
break;
case DHCPREQUEST: