From fb8977c5be93f8e967df224fe0a44721d60e34dc Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Fri, 13 Sep 2019 19:21:16 -0500 Subject: net: Always build the string_to_enetaddr() helper Part of the env cleanup moved this out of the environment code and into the net code. However, this helper is sometimes needed even when the net stack isn't included. Move the helper to lib/net_utils.c like it's similarly-purposed string_to_ip(). Also rename the moved function to similar naming. Signed-off-by: Joe Hershberger Reported-by: Ondrej Jirman --- lib/net_utils.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/net_utils.c') diff --git a/lib/net_utils.c b/lib/net_utils.c index 9fb9d4a4b0..ed5044c3de 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; + } +} -- cgit