diff options
-rw-r--r-- | include/usage.h | 3 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/include/usage.h b/include/usage.h index 05fe506c8..22beeadf3 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -3239,7 +3239,7 @@ | |||
3239 | "Adjust filesystem options on ext[23] filesystems.\n\n" | 3239 | "Adjust filesystem options on ext[23] filesystems.\n\n" |
3240 | 3240 | ||
3241 | #define udhcpc_trivial_usage \ | 3241 | #define udhcpc_trivial_usage \ |
3242 | "[-Cfbnqv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]" | 3242 | "[-Cfbnqtv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]" |
3243 | #define udhcpc_full_usage \ | 3243 | #define udhcpc_full_usage \ |
3244 | "\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \ | 3244 | "\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \ |
3245 | "\t-C,\t--clientid-none\tSuppress default client identifier\n" \ | 3245 | "\t-C,\t--clientid-none\tSuppress default client identifier\n" \ |
@@ -3254,6 +3254,7 @@ | |||
3254 | "\t-q,\t--quit\tQuit after obtaining lease\n" \ | 3254 | "\t-q,\t--quit\tQuit after obtaining lease\n" \ |
3255 | "\t-r,\t--request=IP\tIP address to request (default: none)\n" \ | 3255 | "\t-r,\t--request=IP\tIP address to request (default: none)\n" \ |
3256 | "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \ | 3256 | "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \ |
3257 | "\t-t,\t--retries=NUM\tSend up to NUM request packets\n"\ | ||
3257 | "\t-v,\t--version\tDisplay version" | 3258 | "\t-v,\t--version\tDisplay version" |
3258 | 3259 | ||
3259 | #define udhcpd_trivial_usage \ | 3260 | #define udhcpd_trivial_usage \ |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 8568ac1e7..e035bd4c2 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -58,6 +58,7 @@ struct client_config_t client_config = { | |||
58 | .hostname = NULL, | 58 | .hostname = NULL, |
59 | .fqdn = NULL, | 59 | .fqdn = NULL, |
60 | .ifindex = 0, | 60 | .ifindex = 0, |
61 | .retries = 3, | ||
61 | .arp = "\0\0\0\0\0\0", /* appease gcc-3.0 */ | 62 | .arp = "\0\0\0\0\0\0", /* appease gcc-3.0 */ |
62 | }; | 63 | }; |
63 | 64 | ||
@@ -202,13 +203,14 @@ int main(int argc, char *argv[]) | |||
202 | {"request", required_argument, 0, 'r'}, | 203 | {"request", required_argument, 0, 'r'}, |
203 | {"script", required_argument, 0, 's'}, | 204 | {"script", required_argument, 0, 's'}, |
204 | {"version", no_argument, 0, 'v'}, | 205 | {"version", no_argument, 0, 'v'}, |
206 | {"retries", required_argument, 0, 't'}, | ||
205 | {0, 0, 0, 0} | 207 | {0, 0, 0, 0} |
206 | }; | 208 | }; |
207 | 209 | ||
208 | /* get options */ | 210 | /* get options */ |
209 | while (1) { | 211 | while (1) { |
210 | int option_index = 0; | 212 | int option_index = 0; |
211 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:v", arg_options, &option_index); | 213 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:t:v", arg_options, &option_index); |
212 | if (c == -1) break; | 214 | if (c == -1) break; |
213 | 215 | ||
214 | switch (c) { | 216 | switch (c) { |
@@ -284,6 +286,9 @@ int main(int argc, char *argv[]) | |||
284 | case 's': | 286 | case 's': |
285 | client_config.script = optarg; | 287 | client_config.script = optarg; |
286 | break; | 288 | break; |
289 | case 't': | ||
290 | client_config.retries = atoi(optarg); | ||
291 | break; | ||
287 | case 'v': | 292 | case 'v': |
288 | printf("udhcpcd, version %s\n\n", VERSION); | 293 | printf("udhcpcd, version %s\n\n", VERSION); |
289 | return 0; | 294 | return 0; |
@@ -353,7 +358,7 @@ int main(int argc, char *argv[]) | |||
353 | /* timeout dropped to zero */ | 358 | /* timeout dropped to zero */ |
354 | switch (state) { | 359 | switch (state) { |
355 | case INIT_SELECTING: | 360 | case INIT_SELECTING: |
356 | if (packet_num < 3) { | 361 | if (packet_num < client_config.retries) { |
357 | if (packet_num == 0) | 362 | if (packet_num == 0) |
358 | xid = random_xid(); | 363 | xid = random_xid(); |
359 | 364 | ||
@@ -378,7 +383,7 @@ int main(int argc, char *argv[]) | |||
378 | break; | 383 | break; |
379 | case RENEW_REQUESTED: | 384 | case RENEW_REQUESTED: |
380 | case REQUESTING: | 385 | case REQUESTING: |
381 | if (packet_num < 3) { | 386 | if (packet_num < client_config.retries) { |
382 | /* send request packet */ | 387 | /* send request packet */ |
383 | if (state == RENEW_REQUESTED) | 388 | if (state == RENEW_REQUESTED) |
384 | send_renew(xid, server_addr, requested_ip); /* unicast */ | 389 | send_renew(xid, server_addr, requested_ip); /* unicast */ |