Commit fb8977c5be93f8e967df224fe0a44721d60e34dc
1 parent
b38c3a641f
Exists in
smarc_8mq_lf_v2020.04
and in
9 other branches
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 <joe.hershberger@ni.com> Reported-by: Ondrej Jirman <megous@megous.com>
Showing 12 changed files with 39 additions and 37 deletions Side-by-side Diff
arch/arm/mach-tegra/cboot.c
board/renesas/sh7752evb/sh7752evb.c
board/renesas/sh7753evb/sh7753evb.c
board/renesas/sh7757lcr/sh7757lcr.c
... | ... | @@ -141,7 +141,7 @@ |
141 | 141 | unsigned char mac[6]; |
142 | 142 | unsigned long val; |
143 | 143 | |
144 | - eth_parse_enetaddr(mac_string, mac); | |
144 | + string_to_enetaddr(mac_string, mac); | |
145 | 145 | |
146 | 146 | if (!channel) |
147 | 147 | ether = ETHER0_MAC_BASE; |
... | ... | @@ -160,7 +160,7 @@ |
160 | 160 | unsigned char mac[6]; |
161 | 161 | unsigned long val; |
162 | 162 | |
163 | - eth_parse_enetaddr(mac_string, mac); | |
163 | + string_to_enetaddr(mac_string, mac); | |
164 | 164 | |
165 | 165 | if (!channel) |
166 | 166 | ether = GETHER0_MAC_BASE; |
cmd/ethsw.c
... | ... | @@ -864,7 +864,7 @@ |
864 | 864 | return 0; |
865 | 865 | } |
866 | 866 | |
867 | - eth_parse_enetaddr(argv[*argc_nr + 1], parsed_cmd->ethaddr); | |
867 | + string_to_enetaddr(argv[*argc_nr + 1], parsed_cmd->ethaddr); | |
868 | 868 | |
869 | 869 | if (is_broadcast_ethaddr(parsed_cmd->ethaddr)) { |
870 | 870 | memset(parsed_cmd->ethaddr, 0xFF, sizeof(parsed_cmd->ethaddr)); |
cmd/nvedit.c
doc/README.enetaddr
... | ... | @@ -76,12 +76,12 @@ |
76 | 76 | should use these rather than attempt to do any kind of parsing/manipulation |
77 | 77 | yourself as many common errors have arisen in the past. |
78 | 78 | |
79 | - * void eth_parse_enetaddr(const char *addr, uchar *enetaddr); | |
79 | + * void string_to_enetaddr(const char *addr, uchar *enetaddr); | |
80 | 80 | |
81 | 81 | Convert a string representation of a MAC address to the binary version. |
82 | 82 | char *addr = "00:11:22:33:44:55"; |
83 | 83 | uchar enetaddr[6]; |
84 | -eth_parse_enetaddr(addr, enetaddr); | |
84 | +string_to_enetaddr(addr, enetaddr); | |
85 | 85 | /* enetaddr now equals { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } */ |
86 | 86 | |
87 | 87 | * int eth_env_get_enetaddr(char *name, uchar *enetaddr); |
include/net.h
... | ... | @@ -826,6 +826,19 @@ |
826 | 826 | addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ |
827 | 827 | } |
828 | 828 | |
829 | +/** | |
830 | + * string_to_enetaddr() - Parse a MAC address | |
831 | + * | |
832 | + * Convert a string MAC address | |
833 | + * | |
834 | + * Implemented in lib/net_utils.c (built unconditionally) | |
835 | + * | |
836 | + * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit | |
837 | + * hex value | |
838 | + * @enetaddr: Place to put MAC address (6 bytes) | |
839 | + */ | |
840 | +void string_to_enetaddr(const char *addr, uint8_t *enetaddr); | |
841 | + | |
829 | 842 | /* Convert an IP address to a string */ |
830 | 843 | void ip_to_string(struct in_addr x, char *s); |
831 | 844 | |
832 | 845 | |
... | ... | @@ -880,20 +893,7 @@ |
880 | 893 | */ |
881 | 894 | int update_tftp(ulong addr, char *interface, char *devstring); |
882 | 895 | |
883 | -/**********************************************************************/ | |
884 | - | |
885 | 896 | /** |
886 | - * eth_parse_enetaddr() - Parse a MAC address | |
887 | - * | |
888 | - * Convert a string MAC address | |
889 | - * | |
890 | - * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit | |
891 | - * hex value | |
892 | - * @enetaddr: Place to put MAC address (6 bytes) | |
893 | - */ | |
894 | -void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr); | |
895 | - | |
896 | -/** | |
897 | 897 | * env_get_ip() - Convert an environment value to to an ip address |
898 | 898 | * |
899 | 899 | * @var: Environment variable to convert. The value of this variable must be |
... | ... | @@ -905,6 +905,5 @@ |
905 | 905 | { |
906 | 906 | return string_to_ip(env_get(var)); |
907 | 907 | } |
908 | - | |
909 | 908 | #endif /* __NET_H__ */ |
lib/net_utils.c
... | ... | @@ -41,4 +41,19 @@ |
41 | 41 | addr.s_addr = htonl(addr.s_addr); |
42 | 42 | return addr; |
43 | 43 | } |
44 | + | |
45 | +void string_to_enetaddr(const char *addr, uint8_t *enetaddr) | |
46 | +{ | |
47 | + char *end; | |
48 | + int i; | |
49 | + | |
50 | + if (!enetaddr) | |
51 | + return; | |
52 | + | |
53 | + for (i = 0; i < 6; ++i) { | |
54 | + enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0; | |
55 | + if (addr) | |
56 | + addr = (*end) ? end + 1 : end; | |
57 | + } | |
58 | +} |
net/eth-uclass.c
net/eth_legacy.c
net/net.c
... | ... | @@ -1625,16 +1625,4 @@ |
1625 | 1625 | { |
1626 | 1626 | return string_to_vlan(env_get(var)); |
1627 | 1627 | } |
1628 | - | |
1629 | -void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr) | |
1630 | -{ | |
1631 | - char *end; | |
1632 | - int i; | |
1633 | - | |
1634 | - for (i = 0; i < 6; ++i) { | |
1635 | - enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0; | |
1636 | - if (addr) | |
1637 | - addr = (*end) ? end + 1 : end; | |
1638 | - } | |
1639 | -} |