* grub-core/net/drivers/ieee1275/ofnet.c: Get proper mac address when using qemu.

This commit is contained in:
Avik Sil 2013-08-14 18:03:01 -03:00 committed by Paulo Flabiano Smorigo
parent 6f27a3f659
commit 412ce9165c
2 changed files with 16 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2013-08-14 Avik Sil <aviksil@in.ibm.com>
* grub-core/net/drivers/ieee1275/ofnet.c: Get proper mac address when
using qemu.
2013-08-14 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com> 2013-08-14 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
* .bzrignore: Add bootinfo.txt, grub.chrp, gnulib/float.h, and * .bzrignore: Add bootinfo.txt, grub.chrp, gnulib/float.h, and

View file

@ -202,6 +202,9 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
struct grub_net_card *card; struct grub_net_card *card;
grub_ieee1275_phandle_t devhandle; grub_ieee1275_phandle_t devhandle;
grub_net_link_level_address_t lla; grub_net_link_level_address_t lla;
grub_ssize_t prop_size;
grub_uint64_t prop;
grub_uint8_t *pprop;
char *shortname; char *shortname;
if (grub_strcmp (alias->type, "network") != 0) if (grub_strcmp (alias->type, "network") != 0)
@ -235,16 +238,22 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
card->mtu = t; card->mtu = t;
} }
pprop = (grub_uint8_t *) &prop;
if (grub_ieee1275_get_property (devhandle, "mac-address", if (grub_ieee1275_get_property (devhandle, "mac-address",
&(lla.mac), 6, 0) pprop, sizeof(prop), &prop_size)
&& grub_ieee1275_get_property (devhandle, "local-mac-address", && grub_ieee1275_get_property (devhandle, "local-mac-address",
&(lla.mac), 6, 0)) pprop, sizeof(prop), &prop_size))
{ {
grub_error (GRUB_ERR_IO, "Couldn't retrieve mac address."); grub_error (GRUB_ERR_IO, "Couldn't retrieve mac address.");
grub_print_error (); grub_print_error ();
return 0; return 0;
} }
if (prop_size == 8)
grub_memcpy (&lla.mac, pprop+2, 6);
else
grub_memcpy (&lla.mac, pprop, 6);
lla.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; lla.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
card->default_address = lla; card->default_address = lla;