[PATCH 2/3] net: dhcp: allow to user env var as user class too
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Sun Apr 15 00:05:38 EDT 2012
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
net/dhcp.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/dhcp.c b/net/dhcp.c
index c3c41a0..ecff819 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -211,6 +211,7 @@ struct dhcp_opt dhcp_options[] = {
struct dhcp_param {
unsigned char option;
const char *barebox_var_name;
+ const char *barebox_var_alt_name;
int (*handle)(struct dhcp_param *param, u8 *e);
void *data;
};
@@ -220,8 +221,12 @@ static int dhcp_set_string_options(struct dhcp_param *param, u8 *e)
int str_len;
char* str = param->data;
- if (!str && param->barebox_var_name)
- str = (char*)getenv(param->barebox_var_name);
+ if (!str) {
+ if (param->barebox_var_name)
+ str = (char*)getenv(param->barebox_var_name);
+ else if (param->barebox_var_alt_name)
+ str = (char*)getenv(param->barebox_var_alt_name);
+ }
if (!str)
return 0;
@@ -260,6 +265,7 @@ struct dhcp_param dhcp_params[] = {
.option = DHCP_USER_CLASS,
.handle = dhcp_set_string_options,
.barebox_var_name = "dhcp_user_class",
+ .barebox_var_alt_name = "user",
}, {
.option = DHCP_CLIENT_UUID,
.handle = dhcp_set_string_options,
@@ -712,5 +718,6 @@ 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(user, "user class to send to the DHCP server");
BAREBOX_MAGICVAR(dhcp_tftp_server_name, "TFTP server Name returned from DHCP request");
BAREBOX_MAGICVAR(dhcp_oftree_file, "OF tree returned from DHCP request (option 224)");
--
1.7.9.1
More information about the barebox
mailing list