diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net_utils.c | 15 | ||||
-rw-r--r-- | lib/vsprintf.c | 4 |
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/net_utils.c b/lib/net_utils.c index 9fb9d4a4b05..ed5044c3dec 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -41,3 +41,18 @@ struct in_addr string_to_ip(const char *s) addr.s_addr = htonl(addr.s_addr); return addr; } + +void string_to_enetaddr(const char *addr, uint8_t *enetaddr) +{ + char *end; + int i; + + if (!enetaddr) + return; + + for (i = 0; i < 6; ++i) { + enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0; + if (addr) + addr = (*end) ? end + 1 : end; + } +} diff --git a/lib/vsprintf.c b/lib/vsprintf.c index c6467ecd5ff..b4edee29b0d 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -320,7 +320,6 @@ static char *device_path_string(char *buf, char *end, void *dp, int field_width, #endif #endif -#ifdef CONFIG_CMD_NET static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width, int precision, int flags) { @@ -382,7 +381,6 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width, return string(buf, end, ip4_addr, field_width, precision, flags & ~SPECIAL); } -#endif #ifdef CONFIG_LIB_UUID /* @@ -474,7 +472,6 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, break; } break; -#ifdef CONFIG_CMD_NET case 'm': flags |= SPECIAL; /* Fallthrough */ @@ -493,7 +490,6 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, precision, flags); flags &= ~SPECIAL; break; -#endif #ifdef CONFIG_LIB_UUID case 'U': return uuid_string(buf, end, ptr, field_width, precision, |