Re: [U-Boot] [PATCH] 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?
stefan.althoefer@web.de wrote:
[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.
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@web.de (as@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.
diff -uprN u-boot-orig//common/cmd_nvedit.c u-boot/common/cmd_nvedit.c --- u-boot-orig//common/cmd_nvedit.c 2008-12-02 17:25:31.000000000 +0100 +++ u-boot/common/cmd_nvedit.c 2008-12-02 22:59:36.000000000 +0100 @@ -188,6 +188,8 @@ int _do_setenv (int flag, int argc, char #else (strcmp (name, "serial#") == 0) || #endif
(strcmp (name, "ethaddr1") == 0) ||
((strcmp (name, "ethaddr") == 0)(strcmp (name, "ethaddr2") == 0) ||
How about this as a more scalable solution: (note that some boards have up to "ethaddr5")
(strstr(name, "ethaddr") == name)
#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@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
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

Dear Stefan,
Stefan Althöfer wrote:
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

Dear =?iso-8859-15?Q?Stefan_Alth=F6fer?=,
In message 531234379@web.de 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

Dear Wolfgang Denk
Dear =?iso-8859-15?Q?Stefan_Alth=F6fer?=,
In message 531234379@web.de 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

Stefan Althoefer wrote:
Dear Wolfgang Denk
Dear =?iso-8859-15?Q?Stefan_Alth=F6fer?=,
In message 531234379@web.de 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
I think he meant sscanf(), which should be there.
regards, Ben

Dear Ben,
In message 4947FFDB.9040005@gmail.com you wrote:
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.
...
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
participants (4)
-
Ben Warren
-
Stefan Althoefer
-
Stefan Althöfer
-
Wolfgang Denk