aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2005-09-22 18:59:13 +0000
committerPaul Fox <pgf@brightstareng.com>2005-09-22 18:59:13 +0000
commit28de951b022d39516de271ce0ba53560aa3c5555 (patch)
treef5924f07643c8712acb65115bd50a7aa9ddb3603 /networking/udhcp/dhcpc.c
parent2f9c30a2d567ba7bdb6351e0167eb0b59735b898 (diff)
downloadbusybox-28de951b022d39516de271ce0ba53560aa3c5555.tar.gz
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.c25
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 = {
.pidfile = NULL,
.script = DEFAULT_SCRIPT,
.clientid = NULL,
+ .vendorclass = NULL,
.hostname = NULL,
.fqdn = NULL,
.ifindex = 0,
@@ -77,8 +78,9 @@ static void __attribute__ ((noreturn)) show_usage(void)
{
printf(
"Usage: udhcpc [OPTIONS]\n\n"
-" -c, --clientid=CLIENTID Set client identifier\n"
+" -c, --clientid=CLIENTID Set client identifier - type is first char\n"
" -C, --clientid-none Suppress default client identifier\n"
+" -V, --vendorclass=CLASSID Set vendor class identifier\n"
" -H, --hostname=HOSTNAME Client hostname\n"
" -h Alias for -H\n"
" -F, --fqdn=FQDN Client fully qualified domain name\n"
@@ -199,6 +201,7 @@ int main(int argc, char *argv[])
static const struct option arg_options[] = {
{"clientid", required_argument, 0, 'c'},
{"clientid-none", no_argument, 0, 'C'},
+ {"vendorclass", required_argument, 0, 'V'},
{"foreground", no_argument, 0, 'f'},
{"background", no_argument, 0, 'b'},
{"hostname", required_argument, 0, 'H'},
@@ -217,7 +220,7 @@ int main(int argc, char *argv[])
/* get options */
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "c:CfbH:h:F:i:np:qr:s:v", arg_options, &option_index);
+ c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:v", arg_options, &option_index);
if (c == -1) break;
switch (c) {
@@ -235,6 +238,14 @@ int main(int argc, char *argv[])
if (client_config.clientid) show_usage();
no_clientid = 1;
break;
+ case 'V':
+ len = strlen(optarg) > 255 ? 255 : strlen(optarg);
+ if (client_config.vendorclass) free(client_config.vendorclass);
+ client_config.vendorclass = xmalloc(len + 2);
+ client_config.vendorclass[OPT_CODE] = DHCP_VENDOR;
+ client_config.vendorclass[OPT_LEN] = len;
+ strncpy(client_config.vendorclass + OPT_DATA, optarg, len);
+ break;
case 'f':
client_config.foreground = 1;
break;
@@ -310,6 +321,16 @@ int main(int argc, char *argv[])
memcpy(client_config.clientid + 3, client_config.arp, 6);
}
+ if (!client_config.vendorclass) {
+ client_config.vendorclass = xmalloc(sizeof("udhcp "VERSION) + 2);
+ client_config.vendorclass[OPT_CODE] = DHCP_VENDOR;
+ client_config.vendorclass[OPT_LEN] = sizeof("udhcp "VERSION) - 1;
+ client_config.vendorclass[OPT_DATA] = 1;
+ memcpy(&client_config.vendorclass[OPT_DATA],
+ "udhcp "VERSION, sizeof("udhcp "VERSION) - 1);
+ }
+
+
/* setup the signal pipe */
udhcp_sp_setup();