Skip to contentSkip to conversation

common: nvedit to protect additional ethernet addresses Part 1/1

PATCH New Stefan Althöfer 3 participants 6 messages Dec 4, 2008 – Dec 16, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common: nvedit to protect additional ethernet addresses Part 1/1

Then maybe we should have

#define CONFIG_ENV_PROTECTED_ITEM "ethaddr1,ethaddr2,...."

in board configuration to have the greatest flexibility?

Quoted 41 lines
Quoted 5 lines · stefan.althoefer at web.de

[PATCH] common: nvedit to protect additional ethernet addresses

This patch adds "ethaddr1" and "ethaddr2" to the protected environment variables that can only be written once.

Quoted 8 lines

----
The patch is against "latest" u-boot git-repository

Please be patient if style of submission or patches are offending.

Signed-off-by stefan.althoefer at web.de (as at janz.de)

This needs to be above a '---' line. Also, this format is wrong. It should have a real name and one e-mail address. I recommend using 'git format-patch' for generating patches.

common/cmd_nvedit.c int _do_setenv (int flag, int argc, char · line 194

Quoted 13 lines

----

diff -uprN u-boot-orig//common/cmd_nvedit.c u-boot/common/cmd_nvedit.c

common/cmd_nvedit.c renamed from /common/cmd_nvedit.c +2 -0
@@ -188,6 +188,8 @@ int _do_setenv (int flag, int argc, char
 #else
 		    (strcmp (name, "serial#") == 0) ||
 #endif
+		    (strcmp (name, "ethaddr1") == 0) ||
+		    (strcmp (name, "ethaddr2") == 0) ||
 		    ((strcmp (name, "ethaddr") == 0)
 

How about this as a more scalable solution: (note that some boards have up to "ethaddr5")

       (strstr(name, "ethaddr") == name)
Quoted 7 lines
common/cmd_nvedit.c renamed from /common/cmd_nvedit.c +0 -0
 #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)

&& (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Quoted 3 lines

regards,
Ben

_______________________________________________________________________
Sensationsangebot verl?ngert: WEB.DE FreeDSL - Telefonanschluss + DSL f?r nur 16,37 Euro/mtl.!* http://dsl.web.de/?ac=OM.AD.AD008K13805B7069a

#1 lore raw

PATCH 1/1 common: nvedit to protect additional ethernet addresses Part 1/1

Dear Stefan,

Quoted 7 lines · Stefan Alth?fer

Then maybe we should have

#define CONFIG_ENV_PROTECTED_ITEM "ethaddr1,ethaddr2,...."

in board configuration to have the greatest flexibility?

It might be useful to have a general protection mechanism, but probably not right now. Please implement a general string comparison, either by strncmp() or strstr(). Also, please don't top post.

regards,
Ben

#2 lore raw

PATCH 1/1 common: nvedit to protect additional ethernet addresses Part 1/1

In reply to Stefan Althöfer

Dear =?iso-8859-15?Q?Stefan_Alth=F6fer?=,

Quoted 5 lines · In message <[email protected]> you wrote:

Then maybe we should have

#define CONFIG_ENV_PROTECTED_ITEM "ethaddr1,ethaddr2,...."

in board configuration to have the greatest flexibility?

Jerry Van Baren already showed you an elegant way to solve this using scanf().

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Administration: An ingenious abstraction  in  politics,  designed  to
receive the kicks and cuffs due to the premier or president.
- Ambrose Bierce
#3 lore raw

PATCH 1/1 common: nvedit to protect additional ethernet addresses Part 1/1

Dear Wolfgang Denk

Quoted 11 lines

Dear =?iso-8859-15?Q?Stefan_Alth=F6fer?=,

Quoted 5 lines · In message <[email protected]> you wrote:

Then maybe we should have

#define CONFIG_ENV_PROTECTED_ITEM "ethaddr1,ethaddr2,...."

in board configuration to have the greatest flexibility?

Jerry Van Baren already showed you an elegant way to solve this using scanf().

Is scanf() available in u-boot? I couldn't find it.

-- Stefan

#4 lore raw

PATCH 1/1 common: nvedit to protect additional ethernet addresses Part 1/1

Quoted 13 lines · Stefan Althoefer

Dear Wolfgang Denk

Quoted 10 lines

Dear =?iso-8859-15?Q?Stefan_Alth=F6fer?=,

Quoted 6 lines · In message <[email protected]> you wrote:

Then maybe we should have

#define CONFIG_ENV_PROTECTED_ITEM "ethaddr1,ethaddr2,...."

in board configuration to have the greatest flexibility?

Quoted 8 lines
Quoted 3 lines

Jerry Van Baren already showed you an elegant way to solve this using scanf().

Is scanf() available in u-boot? I couldn't find it.

-- Stefan

I think he meant sscanf(), which should be there.

regards,
Ben

#5 lore raw

PATCH 1/1 common: nvedit to protect additional ethernet addresses Part 1/1

Dear Ben,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 5 lines
Quoted 3 lines

Jerry Van Baren already showed you an elegant way to solve this using scanf().

Is scanf() available in u-boot? I couldn't find it.

...

Quoted 1 line

I think he meant sscanf(), which should be there.

No, we don't have this yet in U-Boot.

But that's a small problem - as long as we just need to parse for an expression like "eth\d*addr" we can easily do this with ten lines of C or so.

If we find we might need sscanf() more often, we might een go as far
and borrow some 200+ lines of code for Linux (i.e., from
"lib/vsprintf.c") :-)

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Don't think; let the machine do it for you!"        - E. C. Berkeley