diff options
author | Paul Fox <pgf@brightstareng.com> | 2005-08-01 14:31:13 +0000 |
---|---|---|
committer | Paul Fox <pgf@brightstareng.com> | 2005-08-01 14:31:13 +0000 |
commit | a39bba33c8649a6be42d5a511a4ac909a8998f90 (patch) | |
tree | d1b043c7ce00828f803894910d644bf7d0b78572 | |
parent | 9d6e0833bc71d602c7e6bf4692de3c8eb63cb819 (diff) | |
download | busybox-w32-a39bba33c8649a6be42d5a511a4ac909a8998f90.tar.gz busybox-w32-a39bba33c8649a6be42d5a511a4ac909a8998f90.tar.bz2 busybox-w32-a39bba33c8649a6be42d5a511a4ac909a8998f90.zip |
allow suppression of default client-id. fixes bug 000037. allows
busybox to match kernel and u-boot behavior with respect to client-id.
-rw-r--r-- | include/usage.h | 5 | ||||
-rw-r--r-- | networking/udhcp/clientpacket.c | 3 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 15 |
3 files changed, 17 insertions, 6 deletions
diff --git a/include/usage.h b/include/usage.h index 363b01cdd..21980eeba 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -2931,9 +2931,10 @@ | |||
2931 | "Adjust filesystem options on ext[23] filesystems.\n\n" | 2931 | "Adjust filesystem options on ext[23] filesystems.\n\n" |
2932 | 2932 | ||
2933 | #define udhcpc_trivial_usage \ | 2933 | #define udhcpc_trivial_usage \ |
2934 | "[-fbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]" | 2934 | "[-Cfbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]" |
2935 | #define udhcpc_full_usage \ | 2935 | #define udhcpc_full_usage \ |
2936 | "\t-c,\t--clientid=CLIENTID\tClient identifier\n" \ | 2936 | "\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \ |
2937 | "\t-C,\t--clientid-none\tSuppress default client identifier\n" \ | ||
2937 | "\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \ | 2938 | "\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \ |
2938 | "\t-h,\t \tAlias for -H\n" \ | 2939 | "\t-h,\t \tAlias for -H\n" \ |
2939 | "\t-f,\t--foreground\tDo not fork after getting lease\n" \ | 2940 | "\t-f,\t--foreground\tDo not fork after getting lease\n" \ |
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c index c5e1c210b..2695b06ed 100644 --- a/networking/udhcp/clientpacket.c +++ b/networking/udhcp/clientpacket.c | |||
@@ -76,7 +76,8 @@ static void init_packet(struct dhcpMessage *packet, char type) | |||
76 | 76 | ||
77 | init_header(packet, type); | 77 | init_header(packet, type); |
78 | memcpy(packet->chaddr, client_config.arp, 6); | 78 | memcpy(packet->chaddr, client_config.arp, 6); |
79 | add_option_string(packet->options, client_config.clientid); | 79 | if (client_config.clientid) |
80 | add_option_string(packet->options, client_config.clientid); | ||
80 | if (client_config.hostname) add_option_string(packet->options, client_config.hostname); | 81 | if (client_config.hostname) add_option_string(packet->options, client_config.hostname); |
81 | if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn); | 82 | if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn); |
82 | add_option_string(packet->options, (uint8_t *) &vendor_id); | 83 | add_option_string(packet->options, (uint8_t *) &vendor_id); |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index eeaf5531d..35ae757e7 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -77,7 +77,8 @@ static void __attribute__ ((noreturn)) show_usage(void) | |||
77 | { | 77 | { |
78 | printf( | 78 | printf( |
79 | "Usage: udhcpc [OPTIONS]\n\n" | 79 | "Usage: udhcpc [OPTIONS]\n\n" |
80 | " -c, --clientid=CLIENTID Client identifier\n" | 80 | " -c, --clientid=CLIENTID Set client identifier\n" |
81 | " -C, --clientid-none Suppress default client identifier\n" | ||
81 | " -H, --hostname=HOSTNAME Client hostname\n" | 82 | " -H, --hostname=HOSTNAME Client hostname\n" |
82 | " -h Alias for -H\n" | 83 | " -h Alias for -H\n" |
83 | " -F, --fqdn=FQDN Client fully qualified domain name\n" | 84 | " -F, --fqdn=FQDN Client fully qualified domain name\n" |
@@ -193,9 +194,11 @@ int main(int argc, char *argv[]) | |||
193 | long now; | 194 | long now; |
194 | int max_fd; | 195 | int max_fd; |
195 | int sig; | 196 | int sig; |
197 | int no_clientid = 0; | ||
196 | 198 | ||
197 | static const struct option arg_options[] = { | 199 | static const struct option arg_options[] = { |
198 | {"clientid", required_argument, 0, 'c'}, | 200 | {"clientid", required_argument, 0, 'c'}, |
201 | {"clientid-none", no_argument, 0, 'C'}, | ||
199 | {"foreground", no_argument, 0, 'f'}, | 202 | {"foreground", no_argument, 0, 'f'}, |
200 | {"background", no_argument, 0, 'b'}, | 203 | {"background", no_argument, 0, 'b'}, |
201 | {"hostname", required_argument, 0, 'H'}, | 204 | {"hostname", required_argument, 0, 'H'}, |
@@ -214,11 +217,12 @@ int main(int argc, char *argv[]) | |||
214 | /* get options */ | 217 | /* get options */ |
215 | while (1) { | 218 | while (1) { |
216 | int option_index = 0; | 219 | int option_index = 0; |
217 | c = getopt_long(argc, argv, "c:fbH:h:F:i:np:qr:s:v", arg_options, &option_index); | 220 | c = getopt_long(argc, argv, "c:CfbH:h:F:i:np:qr:s:v", arg_options, &option_index); |
218 | if (c == -1) break; | 221 | if (c == -1) break; |
219 | 222 | ||
220 | switch (c) { | 223 | switch (c) { |
221 | case 'c': | 224 | case 'c': |
225 | if (no_clientid) show_usage(); | ||
222 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); | 226 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); |
223 | if (client_config.clientid) free(client_config.clientid); | 227 | if (client_config.clientid) free(client_config.clientid); |
224 | client_config.clientid = xmalloc(len + 2); | 228 | client_config.clientid = xmalloc(len + 2); |
@@ -227,6 +231,10 @@ int main(int argc, char *argv[]) | |||
227 | client_config.clientid[OPT_DATA] = '\0'; | 231 | client_config.clientid[OPT_DATA] = '\0'; |
228 | strncpy(client_config.clientid + OPT_DATA, optarg, len); | 232 | strncpy(client_config.clientid + OPT_DATA, optarg, len); |
229 | break; | 233 | break; |
234 | case 'C': | ||
235 | if (client_config.clientid) show_usage(); | ||
236 | no_clientid = 1; | ||
237 | break; | ||
230 | case 'f': | 238 | case 'f': |
231 | client_config.foreground = 1; | 239 | client_config.foreground = 1; |
232 | break; | 240 | break; |
@@ -293,7 +301,8 @@ int main(int argc, char *argv[]) | |||
293 | NULL, client_config.arp) < 0) | 301 | NULL, client_config.arp) < 0) |
294 | return 1; | 302 | return 1; |
295 | 303 | ||
296 | if (!client_config.clientid) { | 304 | /* if not set, and not suppressed, setup the default client ID */ |
305 | if (!client_config.clientid && !no_clientid) { | ||
297 | client_config.clientid = xmalloc(6 + 3); | 306 | client_config.clientid = xmalloc(6 + 3); |
298 | client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; | 307 | client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; |
299 | client_config.clientid[OPT_LEN] = 7; | 308 | client_config.clientid[OPT_LEN] = 7; |