diff options
author | Paul Fox <pgf@brightstareng.com> | 2007-11-07 16:01:28 +0000 |
---|---|---|
committer | Paul Fox <pgf@brightstareng.com> | 2007-11-07 16:01:28 +0000 |
commit | 49cce2b8384d2b425a91785ebf155a692df6986c (patch) | |
tree | 5f7a51e103e8dc1ca4eeec9755189719214cac00 /networking/udhcp/dhcpc.c | |
parent | 6e1b62b18ccc928cfa5ff62eb7030b3e5543c15d (diff) | |
download | busybox-w32-49cce2b8384d2b425a91785ebf155a692df6986c.tar.gz busybox-w32-49cce2b8384d2b425a91785ebf155a692df6986c.tar.bz2 busybox-w32-49cce2b8384d2b425a91785ebf155a692df6986c.zip |
add "-A N" / "--tryagain=N" option to client, to allow altering the
default 60 second wait after failure to get a lease.
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r-- | networking/udhcp/dhcpc.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index e00379b2a..c6f9fe42d 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -144,7 +144,7 @@ int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
144 | int udhcpc_main(int argc, char **argv) | 144 | int udhcpc_main(int argc, char **argv) |
145 | { | 145 | { |
146 | uint8_t *temp, *message; | 146 | uint8_t *temp, *message; |
147 | char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_t; | 147 | char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_A, *str_t; |
148 | uint32_t xid = 0; | 148 | uint32_t xid = 0; |
149 | uint32_t lease = 0; /* can be given as 32-bit quantity */ | 149 | uint32_t lease = 0; /* can be given as 32-bit quantity */ |
150 | unsigned t1 = 0, t2 = 0; /* what a wonderful names */ | 150 | unsigned t1 = 0, t2 = 0; /* what a wonderful names */ |
@@ -179,6 +179,7 @@ int udhcpc_main(int argc, char **argv) | |||
179 | OPT_t = 1 << 16, | 179 | OPT_t = 1 << 16, |
180 | OPT_v = 1 << 17, | 180 | OPT_v = 1 << 17, |
181 | OPT_S = 1 << 18, | 181 | OPT_S = 1 << 18, |
182 | OPT_A = 1 << 19, | ||
182 | }; | 183 | }; |
183 | #if ENABLE_GETOPT_LONG | 184 | #if ENABLE_GETOPT_LONG |
184 | static const char udhcpc_longopts[] ALIGN1 = | 185 | static const char udhcpc_longopts[] ALIGN1 = |
@@ -200,6 +201,7 @@ int udhcpc_main(int argc, char **argv) | |||
200 | "timeout\0" Required_argument "T" | 201 | "timeout\0" Required_argument "T" |
201 | "version\0" No_argument "v" | 202 | "version\0" No_argument "v" |
202 | "retries\0" Required_argument "t" | 203 | "retries\0" Required_argument "t" |
204 | "tryagain\0" Required_argument "A" | ||
203 | "syslog\0" No_argument "S" | 205 | "syslog\0" No_argument "S" |
204 | ; | 206 | ; |
205 | #endif | 207 | #endif |
@@ -208,6 +210,7 @@ int udhcpc_main(int argc, char **argv) | |||
208 | client_config.script = DEFAULT_SCRIPT; | 210 | client_config.script = DEFAULT_SCRIPT; |
209 | client_config.retries = 3; | 211 | client_config.retries = 3; |
210 | client_config.timeout = 3; | 212 | client_config.timeout = 3; |
213 | client_config.tryagain = 60; | ||
211 | 214 | ||
212 | /* Parse command line */ | 215 | /* Parse command line */ |
213 | opt_complementary = "c--C:C--c" // mutually exclusive | 216 | opt_complementary = "c--C:C--c" // mutually exclusive |
@@ -215,10 +218,10 @@ int udhcpc_main(int argc, char **argv) | |||
215 | #if ENABLE_GETOPT_LONG | 218 | #if ENABLE_GETOPT_LONG |
216 | applet_long_options = udhcpc_longopts; | 219 | applet_long_options = udhcpc_longopts; |
217 | #endif | 220 | #endif |
218 | opt = getopt32(argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vS", | 221 | opt = getopt32(argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vSA:", |
219 | &str_c, &str_V, &str_h, &str_h, &str_F, | 222 | &str_c, &str_V, &str_h, &str_h, &str_F, |
220 | &client_config.interface, &client_config.pidfile, &str_r, | 223 | &client_config.interface, &client_config.pidfile, &str_r, |
221 | &client_config.script, &str_T, &str_t | 224 | &client_config.script, &str_T, &str_t, &str_A |
222 | ); | 225 | ); |
223 | 226 | ||
224 | if (opt & OPT_c) | 227 | if (opt & OPT_c) |
@@ -259,6 +262,8 @@ int udhcpc_main(int argc, char **argv) | |||
259 | client_config.timeout = xatoi_u(str_T); | 262 | client_config.timeout = xatoi_u(str_T); |
260 | if (opt & OPT_t) | 263 | if (opt & OPT_t) |
261 | client_config.retries = xatoi_u(str_t); | 264 | client_config.retries = xatoi_u(str_t); |
265 | if (opt & OPT_A) | ||
266 | client_config.tryagain = xatoi_u(str_A); | ||
262 | if (opt & OPT_v) { | 267 | if (opt & OPT_v) { |
263 | puts("version "BB_VER); | 268 | puts("version "BB_VER); |
264 | return 0; | 269 | return 0; |
@@ -355,7 +360,7 @@ int udhcpc_main(int argc, char **argv) | |||
355 | } | 360 | } |
356 | /* wait to try again */ | 361 | /* wait to try again */ |
357 | packet_num = 0; | 362 | packet_num = 0; |
358 | timeout = now + 60; | 363 | timeout = now + client_config.tryagain; |
359 | } | 364 | } |
360 | break; | 365 | break; |
361 | case RENEW_REQUESTED: | 366 | case RENEW_REQUESTED: |