pxe: Use ethact setting for pxe

Get the MAC address using eth_getenv_enetaddr_by_index so that the MAC
address of ethact is used. This enables using the a NIC other than the
first one for PXE boot.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
This commit is contained in:
Rob Herring 2012-12-02 21:00:20 -06:00 committed by Joe Hershberger
parent 0fae25089d
commit ef034c9d70

View File

@ -55,37 +55,21 @@ static char *from_env(char *envvar)
*/ */
static int format_mac_pxe(char *outbuf, size_t outbuf_len) static int format_mac_pxe(char *outbuf, size_t outbuf_len)
{ {
size_t ethaddr_len; uchar ethaddr[6];
char *p, *ethaddr;
ethaddr = from_env("ethaddr"); if (outbuf_len < 21) {
printf("outbuf is too small (%d < 21)\n", outbuf_len);
if (!ethaddr)
return -ENOENT;
ethaddr_len = strlen(ethaddr);
/*
* ethaddr_len + 4 gives room for "01-", ethaddr, and a NUL byte at
* the end.
*/
if (outbuf_len < ethaddr_len + 4) {
printf("outbuf is too small (%d < %d)\n",
outbuf_len, ethaddr_len + 4);
return -EINVAL; return -EINVAL;
} }
strcpy(outbuf, "01-"); if (!eth_getenv_enetaddr_by_index("eth", eth_get_dev_index(),
ethaddr))
return -ENOENT;
for (p = outbuf + 3; *ethaddr; ethaddr++, p++) { sprintf(outbuf, "01-%02x-%02x-%02x-%02x-%02x-%02x",
if (*ethaddr == ':') ethaddr[0], ethaddr[1], ethaddr[2],
*p = '-'; ethaddr[3], ethaddr[4], ethaddr[5]);
else
*p = tolower(*ethaddr);
}
*p = '\0';
return 1; return 1;
} }