diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-26 17:41:00 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-26 17:41:00 +0000 |
commit | e175ff252f9abb7267000571207c9d612728e1b9 (patch) | |
tree | bc6843cbc8ca3d0d2257a9e2349c03358b70b85a /networking | |
parent | 22f6dcb47c32909ca0a3d720b11df5ea86b1e76c (diff) | |
download | busybox-w32-e175ff252f9abb7267000571207c9d612728e1b9.tar.gz busybox-w32-e175ff252f9abb7267000571207c9d612728e1b9.tar.bz2 busybox-w32-e175ff252f9abb7267000571207c9d612728e1b9.zip |
several fixes from openWRT project
Diffstat (limited to 'networking')
-rw-r--r-- | networking/udhcp/dhcpc.c | 14 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.h | 1 | ||||
-rw-r--r-- | networking/udhcp/options.c | 3 | ||||
-rw-r--r-- | networking/udhcp/options.h | 2 |
4 files changed, 17 insertions, 3 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index ff4d5018c..499183f18 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -53,6 +53,7 @@ struct client_config_t client_config = { | |||
53 | .abort_if_no_lease = 0, | 53 | .abort_if_no_lease = 0, |
54 | .foreground = 0, | 54 | .foreground = 0, |
55 | .quit_after_lease = 0, | 55 | .quit_after_lease = 0, |
56 | .release_on_quit = 0, | ||
56 | .background_if_no_lease = 0, | 57 | .background_if_no_lease = 0, |
57 | .interface = "eth0", | 58 | .interface = "eth0", |
58 | .pidfile = NULL, | 59 | .pidfile = NULL, |
@@ -169,6 +170,7 @@ int udhcpc_main(int argc, char *argv[]) | |||
169 | {"now", no_argument, 0, 'n'}, | 170 | {"now", no_argument, 0, 'n'}, |
170 | {"pidfile", required_argument, 0, 'p'}, | 171 | {"pidfile", required_argument, 0, 'p'}, |
171 | {"quit", no_argument, 0, 'q'}, | 172 | {"quit", no_argument, 0, 'q'}, |
173 | {"release", no_argument, 0, 'R'}, | ||
172 | {"request", required_argument, 0, 'r'}, | 174 | {"request", required_argument, 0, 'r'}, |
173 | {"script", required_argument, 0, 's'}, | 175 | {"script", required_argument, 0, 's'}, |
174 | {"timeout", required_argument, 0, 'T'}, | 176 | {"timeout", required_argument, 0, 'T'}, |
@@ -180,7 +182,7 @@ int udhcpc_main(int argc, char *argv[]) | |||
180 | /* get options */ | 182 | /* get options */ |
181 | while (1) { | 183 | while (1) { |
182 | int option_index = 0; | 184 | int option_index = 0; |
183 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:T:t:v", arg_options, &option_index); | 185 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v", arg_options, &option_index); |
184 | if (c == -1) break; | 186 | if (c == -1) break; |
185 | 187 | ||
186 | switch (c) { | 188 | switch (c) { |
@@ -250,6 +252,9 @@ int udhcpc_main(int argc, char *argv[]) | |||
250 | case 'q': | 252 | case 'q': |
251 | client_config.quit_after_lease = 1; | 253 | client_config.quit_after_lease = 1; |
252 | break; | 254 | break; |
255 | case 'R': | ||
256 | client_config.release_on_quit = 1; | ||
257 | break; | ||
253 | case 'r': | 258 | case 'r': |
254 | requested_ip = inet_addr(optarg); | 259 | requested_ip = inet_addr(optarg); |
255 | break; | 260 | break; |
@@ -495,8 +500,11 @@ int udhcpc_main(int argc, char *argv[]) | |||
495 | 500 | ||
496 | state = BOUND; | 501 | state = BOUND; |
497 | change_mode(LISTEN_NONE); | 502 | change_mode(LISTEN_NONE); |
498 | if (client_config.quit_after_lease) | 503 | if (client_config.quit_after_lease) { |
504 | if (client_config.release_on_quit) | ||
505 | perform_release(); | ||
499 | return 0; | 506 | return 0; |
507 | } | ||
500 | if (!client_config.foreground) | 508 | if (!client_config.foreground) |
501 | client_background(); | 509 | client_background(); |
502 | 510 | ||
@@ -526,6 +534,8 @@ int udhcpc_main(int argc, char *argv[]) | |||
526 | break; | 534 | break; |
527 | case SIGTERM: | 535 | case SIGTERM: |
528 | bb_info_msg("Received SIGTERM"); | 536 | bb_info_msg("Received SIGTERM"); |
537 | if (client_config.release_on_quit) | ||
538 | perform_release(); | ||
529 | return 0; | 539 | return 0; |
530 | } | 540 | } |
531 | } else if (retval == -1 && errno == EINTR) { | 541 | } else if (retval == -1 && errno == EINTR) { |
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index 3dff11ab0..6cf59a950 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h | |||
@@ -19,6 +19,7 @@ | |||
19 | struct client_config_t { | 19 | struct client_config_t { |
20 | char foreground; /* Do not fork */ | 20 | char foreground; /* Do not fork */ |
21 | char quit_after_lease; /* Quit after obtaining lease */ | 21 | char quit_after_lease; /* Quit after obtaining lease */ |
22 | char release_on_quit; /* perform release on quit */ | ||
22 | char abort_if_no_lease; /* Abort if no lease */ | 23 | char abort_if_no_lease; /* Abort if no lease */ |
23 | char background_if_no_lease; /* Fork to background if no lease */ | 24 | char background_if_no_lease; /* Fork to background if no lease */ |
24 | char *interface; /* The name of the interface to use */ | 25 | char *interface; /* The name of the interface to use */ |
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index 652647229..ded0f7b9b 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c | |||
@@ -42,8 +42,11 @@ struct dhcp_option dhcp_options[] = { | |||
42 | {"dhcptype", OPTION_U8, 0x35}, | 42 | {"dhcptype", OPTION_U8, 0x35}, |
43 | {"serverid", OPTION_IP, 0x36}, | 43 | {"serverid", OPTION_IP, 0x36}, |
44 | {"message", OPTION_STRING, 0x38}, | 44 | {"message", OPTION_STRING, 0x38}, |
45 | {"vendorclass", OPTION_STRING, 0x3C}, | ||
46 | {"clientid", OPTION_STRING, 0x3D}, | ||
45 | {"tftp", OPTION_STRING, 0x42}, | 47 | {"tftp", OPTION_STRING, 0x42}, |
46 | {"bootfile", OPTION_STRING, 0x43}, | 48 | {"bootfile", OPTION_STRING, 0x43}, |
49 | {"userclass", OPTION_STRING, 0x4D}, | ||
47 | {"", 0x00, 0x00} | 50 | {"", 0x00, 0x00} |
48 | }; | 51 | }; |
49 | 52 | ||
diff --git a/networking/udhcp/options.h b/networking/udhcp/options.h index b0a649fef..3c1f5b921 100644 --- a/networking/udhcp/options.h +++ b/networking/udhcp/options.h | |||
@@ -23,7 +23,7 @@ enum { | |||
23 | #define OPTION_LIST 0x20 /* There can be a list of 1 or more of these */ | 23 | #define OPTION_LIST 0x20 /* There can be a list of 1 or more of these */ |
24 | 24 | ||
25 | struct dhcp_option { | 25 | struct dhcp_option { |
26 | char name[10]; | 26 | char name[12]; |
27 | char flags; | 27 | char flags; |
28 | uint8_t code; | 28 | uint8_t code; |
29 | }; | 29 | }; |