return -ENOENT;
}
- eth_parse_enetaddr(prop, mac);
+ string_to_enetaddr(prop, mac);
if (!is_valid_ethaddr(mac)) {
printf("Invalid MAC address: %s\n", prop);
unsigned char mac[6];
unsigned long val;
- eth_parse_enetaddr(mac_string, mac);
+ string_to_enetaddr(mac_string, mac);
if (!channel)
ether = GETHER0_MAC_BASE;
unsigned char mac[6];
unsigned long val;
- eth_parse_enetaddr(mac_string, mac);
+ string_to_enetaddr(mac_string, mac);
if (!channel)
ether = GETHER0_MAC_BASE;
unsigned char mac[6];
unsigned long val;
- eth_parse_enetaddr(mac_string, mac);
+ string_to_enetaddr(mac_string, mac);
if (!channel)
ether = ETHER0_MAC_BASE;
unsigned char mac[6];
unsigned long val;
- eth_parse_enetaddr(mac_string, mac);
+ string_to_enetaddr(mac_string, mac);
if (!channel)
ether = GETHER0_MAC_BASE;
return 0;
}
- eth_parse_enetaddr(argv[*argc_nr + 1], parsed_cmd->ethaddr);
+ string_to_enetaddr(argv[*argc_nr + 1], parsed_cmd->ethaddr);
if (is_broadcast_ethaddr(parsed_cmd->ethaddr)) {
memset(parsed_cmd->ethaddr, 0xFF, sizeof(parsed_cmd->ethaddr));
int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr)
{
- eth_parse_enetaddr(env_get(name), enetaddr);
+ string_to_enetaddr(env_get(name), enetaddr);
return is_valid_ethaddr(enetaddr);
}
should use these rather than attempt to do any kind of parsing/manipulation
yourself as many common errors have arisen in the past.
- * void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
+ * void string_to_enetaddr(const char *addr, uchar *enetaddr);
Convert a string representation of a MAC address to the binary version.
char *addr = "00:11:22:33:44:55";
uchar enetaddr[6];
-eth_parse_enetaddr(addr, enetaddr);
+string_to_enetaddr(addr, enetaddr);
/* enetaddr now equals { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } */
* int eth_env_get_enetaddr(char *name, uchar *enetaddr);
addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
}
+/**
+ * string_to_enetaddr() - Parse a MAC address
+ *
+ * Convert a string MAC address
+ *
+ * Implemented in lib/net_utils.c (built unconditionally)
+ *
+ * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit
+ * hex value
+ * @enetaddr: Place to put MAC address (6 bytes)
+ */
+void string_to_enetaddr(const char *addr, uint8_t *enetaddr);
+
/* Convert an IP address to a string */
void ip_to_string(struct in_addr x, char *s);
*/
int update_tftp(ulong addr, char *interface, char *devstring);
-/**********************************************************************/
-
-/**
- * eth_parse_enetaddr() - Parse a MAC address
- *
- * Convert a string MAC address
- *
- * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit
- * hex value
- * @enetaddr: Place to put MAC address (6 bytes)
- */
-void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr);
-
/**
* env_get_ip() - Convert an environment value to to an ip address
*
{
return string_to_ip(env_get(var));
}
-
#endif /* __NET_H__ */
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;
+ }
+}
switch (op) {
case env_op_create:
case env_op_overwrite:
- eth_parse_enetaddr(value, pdata->enetaddr);
+ string_to_enetaddr(value, pdata->enetaddr);
eth_write_hwaddr(dev);
break;
case env_op_delete:
switch (op) {
case env_op_create:
case env_op_overwrite:
- eth_parse_enetaddr(value, dev->enetaddr);
+ string_to_enetaddr(value, dev->enetaddr);
eth_write_hwaddr(dev, "eth", dev->index);
break;
case env_op_delete:
{
return string_to_vlan(env_get(var));
}
-
-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;
- }
-}