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 @@
28//usage: "\n -f Run in foreground" 28//usage: "\n -f Run in foreground"
29//usage: "\n -S Log to syslog too" 29//usage: "\n -S Log to syslog too"
30//usage: "\n -I ADDR Local address" 30//usage: "\n -I ADDR Local address"
31//usage: "\n -a MSEC Timeout for ARP ping (default 2000)"
31//usage: IF_FEATURE_UDHCP_PORT( 32//usage: IF_FEATURE_UDHCP_PORT(
32//usage: "\n -P N Use port N (default 67)" 33//usage: "\n -P N Use port N (default 67)"
33//usage: ) 34//usage: )
@@ -148,7 +149,8 @@ static uint32_t select_lease_time(struct dhcp_packet *packet)
148static NOINLINE void send_offer(struct dhcp_packet *oldpacket, 149static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
149 uint32_t static_lease_nip, 150 uint32_t static_lease_nip,
150 struct dyn_lease *lease, 151 struct dyn_lease *lease,
151 uint8_t *requested_ip_opt) 152 uint8_t *requested_ip_opt,
153 unsigned arpping_ms)
152{ 154{
153 struct dhcp_packet packet; 155 struct dhcp_packet packet;
154 uint32_t lease_time_sec; 156 uint32_t lease_time_sec;
@@ -187,7 +189,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
187 } 189 }
188 else { 190 else {
189 /* Otherwise, find a free IP */ 191 /* Otherwise, find a free IP */
190 packet.yiaddr = find_free_or_expired_nip(oldpacket->chaddr); 192 packet.yiaddr = find_free_or_expired_nip(oldpacket->chaddr, arpping_ms);
191 } 193 }
192 194
193 if (!packet.yiaddr) { 195 if (!packet.yiaddr) {
@@ -304,6 +306,8 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
304 unsigned opt; 306 unsigned opt;
305 struct option_set *option; 307 struct option_set *option;
306 char *str_I = str_I; 308 char *str_I = str_I;
309 const char *str_a = "2000";
310 unsigned arpping_ms;
307 IF_FEATURE_UDHCP_PORT(char *str_P;) 311 IF_FEATURE_UDHCP_PORT(char *str_P;)
308 312
309#if ENABLE_FEATURE_UDHCP_PORT 313#if ENABLE_FEATURE_UDHCP_PORT
@@ -314,9 +318,10 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
314#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 318#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
315 opt_complementary = "vv"; 319 opt_complementary = "vv";
316#endif 320#endif
317 opt = getopt32(argv, "fSI:v" 321 opt = getopt32(argv, "fSI:va:"
318 IF_FEATURE_UDHCP_PORT("P:") 322 IF_FEATURE_UDHCP_PORT("P:")
319 , &str_I 323 , &str_I
324 , &str_a
320 IF_FEATURE_UDHCP_PORT(, &str_P) 325 IF_FEATURE_UDHCP_PORT(, &str_P)
321 IF_UDHCP_VERBOSE(, &dhcp_verbose) 326 IF_UDHCP_VERBOSE(, &dhcp_verbose)
322 ); 327 );
@@ -336,11 +341,13 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
336 free(lsa); 341 free(lsa);
337 } 342 }
338#if ENABLE_FEATURE_UDHCP_PORT 343#if ENABLE_FEATURE_UDHCP_PORT
339 if (opt & 16) { /* -P */ 344 if (opt & 32) { /* -P */
340 SERVER_PORT = xatou16(str_P); 345 SERVER_PORT = xatou16(str_P);
341 CLIENT_PORT = SERVER_PORT + 1; 346 CLIENT_PORT = SERVER_PORT + 1;
342 } 347 }
343#endif 348#endif
349 arpping_ms = xatou(str_a);
350
344 /* Would rather not do read_config before daemonization - 351 /* Would rather not do read_config before daemonization -
345 * otherwise NOMMU machines will parse config twice */ 352 * otherwise NOMMU machines will parse config twice */
346 read_config(argv[0] ? argv[0] : DHCPD_CONF_FILE); 353 read_config(argv[0] ? argv[0] : DHCPD_CONF_FILE);
@@ -498,7 +505,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
498 case DHCPDISCOVER: 505 case DHCPDISCOVER:
499 log1("Received DISCOVER"); 506 log1("Received DISCOVER");
500 507
501 send_offer(&packet, static_lease_nip, lease, requested_ip_opt); 508 send_offer(&packet, static_lease_nip, lease, requested_ip_opt, arpping_ms);
502 break; 509 break;
503 510
504 case DHCPREQUEST: 511 case DHCPREQUEST: