summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-03-30 11:20:31 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-04-03 11:39:29 +0800
commitf76899fa9805178cf7c71daaecd4065d43ca068f (patch)
treed9e6e3797b7fc8d40ec281c8829d854ecadc877d
parentc106abc619e1c6213c9646615f211499a46e45cb (diff)
downloadbarebox-f76899fa9805178cf7c71daaecd4065d43ca068f.tar.gz
barebox-f76899fa9805178cf7c71daaecd4065d43ca068f.tar.xz
net: dhcp: allow to set transmitted user class
For net boot setups it is useful to submit boot params like server or bootfile over dhcp. To distinguish diffrent type of OS running on the same hardware, a custom vendor id can be sent in dhcp discover/request messages. E.g. the ISC dhcp server can be configured with | option client-uuid code 97 = { unsigned integer 8, string }; | class "at91sam9x5ek" { | match if substring (option vendor-class-identifier,0,20) = "barebox-at91sam9x5ek"; | | filename "/tftpboot/atmel/at91sam9x5/sam9x5ek/zImage"; | if substring (option dhcp-client-identifier,0,7) = "ser2net" { | filename "/tftpboot/atmel/at91sam9x5/sam9x5ek/zImage-ser2net"; | } | if substring (option client-uuid,0,7) = "test" { | filename "/tftpboot/atmel/at91sam9x5/sam9x5ek/zImage-ser2net"; | } | if substring (option user-class,0,4) = "toto" { | filename "/tftpboot/atmel/at91sam9x5/sam9x5ek/zImage-toto"; | } | option tftp-server-name "192.168.200.98"; | option option-150 192.168.200.98; | next-server 192.168.200.98; | option root-path "192.168.200.98:/opt/work/buildroot/build/sam9x5/target"; | } Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
-rw-r--r--net/dhcp.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/net/dhcp.c b/net/dhcp.c
index c7c62716b1..ad32b535e3 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -235,6 +235,7 @@ static int dhcp_set_string_options(struct dhcp_param *param, u8 *e)
#define DHCP_VENDOR_ID 60
#define DHCP_CLIENT_ID 61
+#define DHCP_USER_CLASS 77
#define DHCP_CLIENT_UUID 97
struct dhcp_param dhcp_params[] = {
@@ -247,6 +248,10 @@ struct dhcp_param dhcp_params[] = {
.handle = dhcp_set_string_options,
.barebox_var_name = "dhcp_client_id",
}, {
+ .option = DHCP_USER_CLASS,
+ .handle = dhcp_set_string_options,
+ .barebox_var_name = "dhcp_user_class",
+ }, {
.option = DHCP_CLIENT_UUID,
.handle = dhcp_set_string_options,
.barebox_var_name = "dhcp_client_uuid",
@@ -605,7 +610,7 @@ static int do_dhcp(int argc, char *argv[])
dhcp_reset_env();
- while((opt = getopt(argc, argv, "v:c:u:")) > 0) {
+ while((opt = getopt(argc, argv, "v:c:u:U:")) > 0) {
switch(opt) {
case 'v':
dhcp_set_param_data(DHCP_VENDOR_ID, optarg);
@@ -616,6 +621,9 @@ static int do_dhcp(int argc, char *argv[])
case 'u':
dhcp_set_param_data(DHCP_CLIENT_UUID, optarg);
break;
+ case 'U':
+ dhcp_set_param_data(DHCP_USER_CLASS, optarg);
+ break;
}
}
@@ -671,6 +679,10 @@ BAREBOX_CMD_HELP_OPT ("-c <client_id>",
BAREBOX_CMD_HELP_OPT ("-u <client_uuid>",
"DHCP Client UUID (code 97) submitted in DHCP requests. It can\n"
"be used in the DHCP server's configuration to select options\n"
+"(e.g. bootfile or server) which are valid for barebox clients only.\n")
+BAREBOX_CMD_HELP_OPT ("-U <user_class>",
+"DHCP User class (code 77) submitted in DHCP requests. It can\n"
+"be used in the DHCP server's configuration to select options\n"
"(e.g. bootfile or server) which are valid for barebox clients only.\n");
BAREBOX_CMD_HELP_END
@@ -688,4 +700,5 @@ BAREBOX_MAGICVAR(rootpath, "rootpath returned from DHCP request");
BAREBOX_MAGICVAR(dhcp_vendor_id, "vendor id to send to the DHCP server");
BAREBOX_MAGICVAR(dhcp_client_uuid, "cliend uuid to send to the DHCP server");
BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server");
+BAREBOX_MAGICVAR(dhcp_user_class, "user class to send to the DHCP server");
BAREBOX_MAGICVAR(dhcp_tftp_server_name, "TFTP server Name returned from DHCP request");