aboutsummaryrefslogtreecommitdiff
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
parent2f9c30a2d567ba7bdb6351e0167eb0b59735b898 (diff)
downloadbusybox-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.
-rw-r--r--include/usage.h3
-rw-r--r--networking/udhcp/README.udhcpc4
-rw-r--r--networking/udhcp/clientpacket.c7
-rw-r--r--networking/udhcp/dhcpc.c25
-rw-r--r--networking/udhcp/dhcpc.h1
5 files changed, 30 insertions, 10 deletions
diff --git a/include/usage.h b/include/usage.h
index f702729e5..8b1a8d785 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -2998,10 +2998,11 @@
2998 "Adjust filesystem options on ext[23] filesystems.\n\n" 2998 "Adjust filesystem options on ext[23] filesystems.\n\n"
2999 2999
3000#define udhcpc_trivial_usage \ 3000#define udhcpc_trivial_usage \
3001 "[-Cfbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]" 3001 "[-Cfbnqv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
3002#define udhcpc_full_usage \ 3002#define udhcpc_full_usage \
3003 "\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \ 3003 "\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \
3004 "\t-C,\t--clientid-none\tSuppress default client identifier\n" \ 3004 "\t-C,\t--clientid-none\tSuppress default client identifier\n" \
3005 "\t-V,\t--vendorclass=CLASSID\tSet vendor class identifier\n" \
3005 "\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \ 3006 "\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \
3006 "\t-h,\t \tAlias for -H\n" \ 3007 "\t-h,\t \tAlias for -H\n" \
3007 "\t-f,\t--foreground\tDo not fork after getting lease\n" \ 3008 "\t-f,\t--foreground\tDo not fork after getting lease\n" \
diff --git a/networking/udhcp/README.udhcpc b/networking/udhcp/README.udhcpc
index e19bf3750..0417ff2ab 100644
--- a/networking/udhcp/README.udhcpc
+++ b/networking/udhcp/README.udhcpc
@@ -10,7 +10,9 @@ command line options
10 10
11The command line options for the udhcp client are: 11The command line options for the udhcp client are:
12 12
13-c, --clientid=CLIENTID Client identifier 13-c, --clientid=CLIENTID Set client identifier. Type is first char.
14-C, --clientid-none Suppress default client identifier
15-V, --vendorclass=CLASSID Set vendor class identifier
14-H, --hostname=HOSTNAME Client hostname 16-H, --hostname=HOSTNAME Client hostname
15-h, Alias for -H 17-h, Alias for -H
16-F, --fqdn=FQDN Client fully qualified domain name 18-F, --fqdn=FQDN Client fully qualified domain name
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 2695b06ed..528befde6 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -69,18 +69,13 @@ unsigned long random_xid(void)
69/* initialize a packet with the proper defaults */ 69/* initialize a packet with the proper defaults */
70static void init_packet(struct dhcpMessage *packet, char type) 70static void init_packet(struct dhcpMessage *packet, char type)
71{ 71{
72 struct vendor {
73 char vendor, length;
74 char str[sizeof("udhcp "VERSION)];
75 } vendor_id = { DHCP_VENDOR, sizeof("udhcp "VERSION) - 1, "udhcp "VERSION};
76
77 init_header(packet, type); 72 init_header(packet, type);
78 memcpy(packet->chaddr, client_config.arp, 6); 73 memcpy(packet->chaddr, client_config.arp, 6);
79 if (client_config.clientid) 74 if (client_config.clientid)
80 add_option_string(packet->options, client_config.clientid); 75 add_option_string(packet->options, client_config.clientid);
81 if (client_config.hostname) add_option_string(packet->options, client_config.hostname); 76 if (client_config.hostname) add_option_string(packet->options, client_config.hostname);
82 if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn); 77 if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn);
83 add_option_string(packet->options, (uint8_t *) &vendor_id); 78 add_option_string(packet->options, client_config.vendorclass);
84} 79}
85 80
86 81
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
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h
index 77c180944..4cc1c4cc1 100644
--- a/networking/udhcp/dhcpc.h
+++ b/networking/udhcp/dhcpc.h
@@ -26,6 +26,7 @@ struct client_config_t {
26 char *pidfile; /* Optionally store the process ID */ 26 char *pidfile; /* Optionally store the process ID */
27 char *script; /* User script to run at dhcp events */ 27 char *script; /* User script to run at dhcp events */
28 uint8_t *clientid; /* Optional client id to use */ 28 uint8_t *clientid; /* Optional client id to use */
29 uint8_t *vendorclass; /* Optional vendor class-id to use */
29 uint8_t *hostname; /* Optional hostname to use */ 30 uint8_t *hostname; /* Optional hostname to use */
30 uint8_t *fqdn; /* Optional fully qualified domain name to use */ 31 uint8_t *fqdn; /* Optional fully qualified domain name to use */
31 int ifindex; /* Index number of the interface to use */ 32 int ifindex; /* Index number of the interface to use */