mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/3] net: dhcp: allow to user env var as user class too
Date: Sun, 15 Apr 2012 18:57:58 +0200	[thread overview]
Message-ID: <20120415165758.GN3852@pengutronix.de> (raw)
In-Reply-To: <1334462739-17265-2-git-send-email-plagnioj@jcrosoft.com>

On Sun, Apr 15, 2012 at 06:05:38AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@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");

This does not look good. I think 'user' is a too generic name to be a
magicvar, also it does not fit into the current dhcp_ scheme. Why not
add a dhcp_user_class=$user to the environment if necessary?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-04-15 16:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-15  4:05 [PATCH 1/3] net: dhcp: add support to send the hostname to the dhcp server Jean-Christophe PLAGNIOL-VILLARD
2012-04-15  4:05 ` [PATCH 2/3] net: dhcp: allow to user env var as user class too Jean-Christophe PLAGNIOL-VILLARD
2012-04-15 16:57   ` Sascha Hauer [this message]
2012-04-15 16:49     ` Jean-Christophe PLAGNIOL-VILLARD
2012-04-15  4:05 ` [PATCH 3/3] config: switch machine to hostname Jean-Christophe PLAGNIOL-VILLARD
2012-04-15  7:51 ` [PATCH 1/3] net: dhcp: add support to send the hostname to the dhcp server Baruch Siach
2012-04-15 13:27 ` [PATCH 1/3 v2] " Jean-Christophe PLAGNIOL-VILLARD
2012-04-18 10:05 ` [PATCH 1/3] " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120415165758.GN3852@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox