[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 12:49:05 EDT 2012


On 18:57 Sun 15 Apr     , Sascha Hauer wrote:
> On Sun, Apr 15, 2012 at 06:05:38AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > 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");
> 
> 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?
I known but I want to have a automatic and common way to manage it

without any modification for the user

Best Regards,
J.



More information about the barebox mailing list