summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/elf.c1
-rw-r--r--cmd/ethsw.c1
-rw-r--r--cmd/nvedit.c30
3 files changed, 32 insertions, 0 deletions
diff --git a/cmd/elf.c b/cmd/elf.c
index f874073280d..038796498c0 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -16,6 +16,7 @@
#include <common.h>
#include <command.h>
#include <elf.h>
+#include <environment.h>
#include <net.h>
#include <vxworks.h>
#ifdef CONFIG_X86
diff --git a/cmd/ethsw.c b/cmd/ethsw.c
index b600965e8ad..92a60b4515b 100644
--- a/cmd/ethsw.c
+++ b/cmd/ethsw.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <command.h>
+#include <environment.h>
#include <errno.h>
#include <env_flags.h>
#include <ethsw.h>
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 4cb25b82486..9838678262d 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -341,6 +341,36 @@ ulong env_get_hex(const char *varname, ulong default_val)
return value;
}
+void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr)
+{
+ char *end;
+ int i;
+
+ for (i = 0; i < 6; ++i) {
+ enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
+ if (addr)
+ addr = (*end) ? end + 1 : end;
+ }
+}
+
+int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr)
+{
+ eth_parse_enetaddr(env_get(name), enetaddr);
+ return is_valid_ethaddr(enetaddr);
+}
+
+int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr)
+{
+ char buf[ARP_HLEN_ASCII + 1];
+
+ if (eth_env_get_enetaddr(name, (uint8_t *)buf))
+ return -EEXIST;
+
+ sprintf(buf, "%pM", enetaddr);
+
+ return env_set(name, buf);
+}
+
#ifndef CONFIG_SPL_BUILD
static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{