Commit 7967406801aa897fae83caad3278ac85a342adaa
1 parent
0f03eca6
qemu:virtio-net: Define ETH_ALEN for use when manipulating MAC addresses (Alex Williamson)
Makes it much easier to search too. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6535 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
9 additions
and
7 deletions
hw/virtio-net.c
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | typedef struct VirtIONet |
22 | 22 | { |
23 | 23 | VirtIODevice vdev; |
24 | - uint8_t mac[6]; | |
24 | + uint8_t mac[ETH_ALEN]; | |
25 | 25 | uint16_t status; |
26 | 26 | VirtQueue *rx_vq; |
27 | 27 | VirtQueue *tx_vq; |
... | ... | @@ -46,7 +46,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) |
46 | 46 | struct virtio_net_config netcfg; |
47 | 47 | |
48 | 48 | netcfg.status = n->status; |
49 | - memcpy(netcfg.mac, n->mac, 6); | |
49 | + memcpy(netcfg.mac, n->mac, ETH_ALEN); | |
50 | 50 | memcpy(config, &netcfg, sizeof(netcfg)); |
51 | 51 | } |
52 | 52 | |
... | ... | @@ -57,8 +57,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) |
57 | 57 | |
58 | 58 | memcpy(&netcfg, config, sizeof(netcfg)); |
59 | 59 | |
60 | - if (memcmp(netcfg.mac, n->mac, 6)) { | |
61 | - memcpy(n->mac, netcfg.mac, 6); | |
60 | + if (memcmp(netcfg.mac, n->mac, ETH_ALEN)) { | |
61 | + memcpy(n->mac, netcfg.mac, ETH_ALEN); | |
62 | 62 | qemu_format_nic_info_str(n->vc, n->mac); |
63 | 63 | } |
64 | 64 | } |
... | ... | @@ -304,7 +304,7 @@ static void virtio_net_save(QEMUFile *f, void *opaque) |
304 | 304 | |
305 | 305 | virtio_save(&n->vdev, f); |
306 | 306 | |
307 | - qemu_put_buffer(f, n->mac, 6); | |
307 | + qemu_put_buffer(f, n->mac, ETH_ALEN); | |
308 | 308 | qemu_put_be32(f, n->tx_timer_active); |
309 | 309 | qemu_put_be32(f, n->mergeable_rx_bufs); |
310 | 310 | qemu_put_be16(f, n->status); |
... | ... | @@ -319,7 +319,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) |
319 | 319 | |
320 | 320 | virtio_load(&n->vdev, f); |
321 | 321 | |
322 | - qemu_get_buffer(f, n->mac, 6); | |
322 | + qemu_get_buffer(f, n->mac, ETH_ALEN); | |
323 | 323 | n->tx_timer_active = qemu_get_be32(f); |
324 | 324 | n->mergeable_rx_bufs = qemu_get_be32(f); |
325 | 325 | |
... | ... | @@ -356,7 +356,7 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) |
356 | 356 | n->vdev.set_features = virtio_net_set_features; |
357 | 357 | n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx); |
358 | 358 | n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx); |
359 | - memcpy(n->mac, nd->macaddr, 6); | |
359 | + memcpy(n->mac, nd->macaddr, ETH_ALEN); | |
360 | 360 | n->status = VIRTIO_NET_S_LINK_UP; |
361 | 361 | n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, |
362 | 362 | virtio_net_receive, virtio_net_can_receive, n); | ... | ... |