Revision 283c7c63

b/hw/dp8393x.c
889 889
    s->watchdog = qemu_new_timer(vm_clock, dp8393x_watchdog, s);
890 890
    s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */
891 891

  
892
    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
892
    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->netdev,
893
                                          nd->model, nd->name,
893 894
                                          nic_can_receive, nic_receive, NULL,
894 895
                                          nic_cleanup, s);
895 896

  
b/hw/etraxfs_eth.c
590 590
	eth->ethregs = cpu_register_io_memory(eth_read, eth_write, eth);
591 591
	cpu_register_physical_memory (base, 0x5c, eth->ethregs);
592 592

  
593
	eth->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
593
	eth->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->netdev,
594
                                                nd->model, nd->name,
594 595
                                                eth_can_receive, eth_receive,
595 596
                                                NULL, eth_cleanup, eth);
596 597
	eth->vc->opaque = eth;
b/hw/mcf_fec.c
462 462
                                           mcf_fec_writefn, s);
463 463
    cpu_register_physical_memory(base, 0x400, s->mmio_index);
464 464

  
465
    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
465
    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->netdev,
466
                                          nd->model, nd->name,
466 467
                                          mcf_fec_can_receive, mcf_fec_receive,
467 468
                                          NULL, mcf_fec_cleanup, s);
468 469
    memcpy(s->macaddr, nd->macaddr, 6);
b/hw/mipsnet.c
262 262

  
263 263
    s->io_base = base;
264 264
    s->irq = irq;
265
    if (nd && nd->vlan) {
266
        s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
265
    if (nd) {
266
        s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->netdev,
267
                                              nd->model, nd->name,
267 268
                                              mipsnet_can_receive, mipsnet_receive,
268 269
                                              NULL, mipsnet_cleanup, s);
269 270
    } else {
b/hw/qdev.c
370 370
{
371 371
    NICInfo *nd = dev->nd;
372 372
    assert(nd);
373
    nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, can_receive,
374
                                  receive, receive_iov, cleanup, opaque);
373
    nd->vc = qemu_new_vlan_client(nd->vlan, nd->netdev,
374
                                  nd->model, nd->name,
375
                                  can_receive, receive, receive_iov,
376
                                  cleanup, opaque);
375 377
    return nd->vc;
376 378
}
377 379

  
b/hw/usb-net.c
1460 1460

  
1461 1461
    memcpy(s->mac, nd->macaddr, 6);
1462 1462

  
1463
    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
1463
    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->netdev,
1464
                                          nd->model, nd->name,
1464 1465
                                          usbnet_can_receive,
1465 1466
                                          usbnet_receive,
1466 1467
                                          NULL,
b/hw/xen_nic.c
301 301
	return -1;
302 302

  
303 303
    vlan = qemu_find_vlan(netdev->xendev.dev, 1);
304
    netdev->vs = qemu_new_vlan_client(vlan, "xen", NULL,
304
    netdev->vs = qemu_new_vlan_client(vlan, NULL, "xen", NULL,
305 305
                                      net_rx_ok, net_rx_packet, NULL,
306 306
                                      NULL, netdev);
307 307
    snprintf(netdev->vs->info_str, sizeof(netdev->vs->info_str),
b/net.c
302 302
}
303 303

  
304 304
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
305
                                      VLANClientState *peer,
305 306
                                      const char *model,
306 307
                                      const char *name,
307 308
                                      NetCanReceive *can_receive,
......
326 327
    vc->opaque = opaque;
327 328

  
328 329
    if (vlan) {
330
        assert(!peer);
329 331
        vc->vlan = vlan;
330 332
        QTAILQ_INSERT_TAIL(&vc->vlan->clients, vc, next);
331 333
    } else {
334
        if (peer) {
335
            vc->peer = peer;
336
            peer->peer = vc;
337
        }
332 338
        QTAILQ_INSERT_TAIL(&non_vlan_clients, vc, next);
333 339
    }
334 340

  
......
341 347
        QTAILQ_REMOVE(&vc->vlan->clients, vc, next);
342 348
    } else {
343 349
        QTAILQ_REMOVE(&non_vlan_clients, vc, next);
350
        if (vc->peer) {
351
            vc->peer->peer = NULL;
352
        }
344 353
    }
345 354

  
346 355
    if (vc->cleanup) {
......
866 875
    }
867 876
#endif
868 877

  
869
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive, NULL,
878
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
879
                                 slirp_receive, NULL,
870 880
                                 net_slirp_cleanup, s);
871 881
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
872 882
             "net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
......
1426 1436

  
1427 1437
    s = qemu_mallocz(sizeof(TAPState));
1428 1438
    s->fd = fd;
1429
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, tap_receive,
1430
                                 tap_receive_iov, tap_cleanup, s);
1439
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
1440
                                 tap_receive, tap_receive_iov,
1441
                                 tap_cleanup, s);
1431 1442
    tap_read_poll(s, 1);
1432 1443
    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd);
1433 1444
    return s;
......
1760 1771
        free(s);
1761 1772
        return -1;
1762 1773
    }
1763
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, vde_receive,
1764
                                 NULL, vde_cleanup, s);
1774
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
1775
                                 vde_receive, NULL,
1776
                                 vde_cleanup, s);
1765 1777
    qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
1766 1778
    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d",
1767 1779
             sock, vde_datafd(s->vde));
......
1999 2011
    s = qemu_mallocz(sizeof(NetSocketState));
2000 2012
    s->fd = fd;
2001 2013

  
2002
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, net_socket_receive_dgram,
2003
                                 NULL, net_socket_cleanup, s);
2014
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
2015
                                 net_socket_receive_dgram, NULL,
2016
                                 net_socket_cleanup, s);
2004 2017
    qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s);
2005 2018

  
2006 2019
    /* mcast: save bound address as dst */
......
2027 2040
    NetSocketState *s;
2028 2041
    s = qemu_mallocz(sizeof(NetSocketState));
2029 2042
    s->fd = fd;
2030
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, net_socket_receive,
2031
                                 NULL, net_socket_cleanup, s);
2043
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
2044
                                 net_socket_receive, NULL,
2045
                                 net_socket_cleanup, s);
2032 2046
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
2033 2047
             "socket: fd=%d", fd);
2034 2048
    if (is_connected) {
......
2308 2322
        return -1;
2309 2323
    }
2310 2324

  
2311
    s->pcap_vc = qemu_new_vlan_client(vlan, device, name, NULL, dump_receive, NULL,
2325
    s->pcap_vc = qemu_new_vlan_client(vlan, NULL, device, name, NULL,
2326
                                      dump_receive, NULL,
2312 2327
                                      net_dump_cleanup, s);
2313 2328
    snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),
2314 2329
             "dump to %s (len=%d)", filename, len);
b/net.h
28 28
    void *opaque;
29 29
    QTAILQ_ENTRY(VLANClientState) next;
30 30
    struct VLANState *vlan;
31
    VLANClientState *peer;
31 32
    char *model;
32 33
    char *name;
33 34
    char info_str[256];
......
56 57

  
57 58
VLANState *qemu_find_vlan(int id, int allocate);
58 59
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
60
                                      VLANClientState *peer,
59 61
                                      const char *model,
60 62
                                      const char *name,
61 63
                                      NetCanReceive *can_receive,
b/tap-win32.c
677 677
        return -1;
678 678
    }
679 679

  
680
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, tap_receive,
680
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name,
681
                                 NULL, tap_receive,
681 682
                                 NULL, tap_cleanup, s);
682 683

  
683 684
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),

Also available in: Unified diff