diff options
author | Paul Fox <pgf@brightstareng.com> | 2005-09-22 18:59:13 +0000 |
---|---|---|
committer | Paul Fox <pgf@brightstareng.com> | 2005-09-22 18:59:13 +0000 |
commit | 28de951b022d39516de271ce0ba53560aa3c5555 (patch) | |
tree | f5924f07643c8712acb65115bd50a7aa9ddb3603 /networking/udhcp/dhcpc.c | |
parent | 2f9c30a2d567ba7bdb6351e0167eb0b59735b898 (diff) | |
download | busybox-w32-28de951b022d39516de271ce0ba53560aa3c5555.tar.gz busybox-w32-28de951b022d39516de271ce0ba53560aa3c5555.tar.bz2 busybox-w32-28de951b022d39516de271ce0ba53560aa3c5555.zip |
add support for setting the dhcp vendor class option (option 60).
udhcpc now has a -V (--vendorclass), which will replace the default
"udhcpRELEASE" string in this option.
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r-- | networking/udhcp/dhcpc.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 35ae757e7..48923f697 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -66,6 +66,7 @@ struct client_config_t client_config = { | |||
66 | .pidfile = NULL, | 66 | .pidfile = NULL, |
67 | .script = DEFAULT_SCRIPT, | 67 | .script = DEFAULT_SCRIPT, |
68 | .clientid = NULL, | 68 | .clientid = NULL, |
69 | .vendorclass = NULL, | ||
69 | .hostname = NULL, | 70 | .hostname = NULL, |
70 | .fqdn = NULL, | 71 | .fqdn = NULL, |
71 | .ifindex = 0, | 72 | .ifindex = 0, |
@@ -77,8 +78,9 @@ static void __attribute__ ((noreturn)) show_usage(void) | |||
77 | { | 78 | { |
78 | printf( | 79 | printf( |
79 | "Usage: udhcpc [OPTIONS]\n\n" | 80 | "Usage: udhcpc [OPTIONS]\n\n" |
80 | " -c, --clientid=CLIENTID Set client identifier\n" | 81 | " -c, --clientid=CLIENTID Set client identifier - type is first char\n" |
81 | " -C, --clientid-none Suppress default client identifier\n" | 82 | " -C, --clientid-none Suppress default client identifier\n" |
83 | " -V, --vendorclass=CLASSID Set vendor class identifier\n" | ||
82 | " -H, --hostname=HOSTNAME Client hostname\n" | 84 | " -H, --hostname=HOSTNAME Client hostname\n" |
83 | " -h Alias for -H\n" | 85 | " -h Alias for -H\n" |
84 | " -F, --fqdn=FQDN Client fully qualified domain name\n" | 86 | " -F, --fqdn=FQDN Client fully qualified domain name\n" |
@@ -199,6 +201,7 @@ int main(int argc, char *argv[]) | |||
199 | static const struct option arg_options[] = { | 201 | static const struct option arg_options[] = { |
200 | {"clientid", required_argument, 0, 'c'}, | 202 | {"clientid", required_argument, 0, 'c'}, |
201 | {"clientid-none", no_argument, 0, 'C'}, | 203 | {"clientid-none", no_argument, 0, 'C'}, |
204 | {"vendorclass", required_argument, 0, 'V'}, | ||
202 | {"foreground", no_argument, 0, 'f'}, | 205 | {"foreground", no_argument, 0, 'f'}, |
203 | {"background", no_argument, 0, 'b'}, | 206 | {"background", no_argument, 0, 'b'}, |
204 | {"hostname", required_argument, 0, 'H'}, | 207 | {"hostname", required_argument, 0, 'H'}, |
@@ -217,7 +220,7 @@ int main(int argc, char *argv[]) | |||
217 | /* get options */ | 220 | /* get options */ |
218 | while (1) { | 221 | while (1) { |
219 | int option_index = 0; | 222 | int option_index = 0; |
220 | c = getopt_long(argc, argv, "c:CfbH:h:F:i:np:qr:s:v", arg_options, &option_index); | 223 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:v", arg_options, &option_index); |
221 | if (c == -1) break; | 224 | if (c == -1) break; |
222 | 225 | ||
223 | switch (c) { | 226 | switch (c) { |
@@ -235,6 +238,14 @@ int main(int argc, char *argv[]) | |||
235 | if (client_config.clientid) show_usage(); | 238 | if (client_config.clientid) show_usage(); |
236 | no_clientid = 1; | 239 | no_clientid = 1; |
237 | break; | 240 | break; |
241 | case 'V': | ||
242 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); | ||
243 | if (client_config.vendorclass) free(client_config.vendorclass); | ||
244 | client_config.vendorclass = xmalloc(len + 2); | ||
245 | client_config.vendorclass[OPT_CODE] = DHCP_VENDOR; | ||
246 | client_config.vendorclass[OPT_LEN] = len; | ||
247 | strncpy(client_config.vendorclass + OPT_DATA, optarg, len); | ||
248 | break; | ||
238 | case 'f': | 249 | case 'f': |
239 | client_config.foreground = 1; | 250 | client_config.foreground = 1; |
240 | break; | 251 | break; |
@@ -310,6 +321,16 @@ int main(int argc, char *argv[]) | |||
310 | memcpy(client_config.clientid + 3, client_config.arp, 6); | 321 | memcpy(client_config.clientid + 3, client_config.arp, 6); |
311 | } | 322 | } |
312 | 323 | ||
324 | if (!client_config.vendorclass) { | ||
325 | client_config.vendorclass = xmalloc(sizeof("udhcp "VERSION) + 2); | ||
326 | client_config.vendorclass[OPT_CODE] = DHCP_VENDOR; | ||
327 | client_config.vendorclass[OPT_LEN] = sizeof("udhcp "VERSION) - 1; | ||
328 | client_config.vendorclass[OPT_DATA] = 1; | ||
329 | memcpy(&client_config.vendorclass[OPT_DATA], | ||
330 | "udhcp "VERSION, sizeof("udhcp "VERSION) - 1); | ||
331 | } | ||
332 | |||
333 | |||
313 | /* setup the signal pipe */ | 334 | /* setup the signal pipe */ |
314 | udhcp_sp_setup(); | 335 | udhcp_sp_setup(); |
315 | 336 | ||