Revision cda9046b

b/hw/dp8393x.c
409 409
            s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
410 410
            if (s->vc->fd_can_read(s)) {
411 411
                s->loopback_packet = 1;
412
                s->vc->fd_read(s, s->tx_buffer, tx_len);
412
                s->vc->receive(s, s->tx_buffer, tx_len);
413 413
            }
414 414
        } else {
415 415
            /* Transmit packet */
......
725 725
    return -1;
726 726
}
727 727

  
728
static void nic_receive(void *opaque, const uint8_t * buf, int size)
728
static void nic_receive(void *opaque, const uint8_t * buf, size_t size)
729 729
{
730 730
    uint16_t data[10];
731 731
    dp8393xState *s = opaque;
b/hw/e1000.c
600 600
}
601 601

  
602 602
static void
603
e1000_receive(void *opaque, const uint8_t *buf, int size)
603
e1000_receive(void *opaque, const uint8_t *buf, size_t size)
604 604
{
605 605
    E1000State *s = opaque;
606 606
    struct e1000_rx_desc desc;
......
614 614
        return;
615 615

  
616 616
    if (size > s->rxbuf_size) {
617
        DBGOUT(RX, "packet too large for buffers (%d > %d)\n", size,
618
               s->rxbuf_size);
617
        DBGOUT(RX, "packet too large for buffers (%lu > %d)\n",
618
               (unsigned long)size, s->rxbuf_size);
619 619
        return;
620 620
    }
621 621

  
b/hw/eepro100.c
1441 1441
    //~ return !eepro100_buffer_full(s);
1442 1442
}
1443 1443

  
1444
static void nic_receive(void *opaque, const uint8_t * buf, int size)
1444
static void nic_receive(void *opaque, const uint8_t * buf, size_t size)
1445 1445
{
1446 1446
    /* TODO:
1447 1447
     * - Magic packets should set bit 30 in power management driver register.
b/hw/etraxfs_eth.c
501 501
	return 1;
502 502
}
503 503

  
504
static void eth_receive(void *opaque, const uint8_t *buf, int size)
504
static void eth_receive(void *opaque, const uint8_t *buf, size_t size)
505 505
{
506 506
	unsigned char sa_bcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
507 507
	struct fs_eth *eth = opaque;
b/hw/mcf_fec.c
353 353
    return s->rx_enabled;
354 354
}
355 355

  
356
static void mcf_fec_receive(void *opaque, const uint8_t *buf, int size)
356
static void mcf_fec_receive(void *opaque, const uint8_t *buf, size_t size)
357 357
{
358 358
    mcf_fec_state *s = (mcf_fec_state *)opaque;
359 359
    mcf_fec_bd bd;
b/hw/mipsnet.c
75 75
    return !mipsnet_buffer_full(s);
76 76
}
77 77

  
78
static void mipsnet_receive(void *opaque, const uint8_t *buf, int size)
78
static void mipsnet_receive(void *opaque, const uint8_t *buf, size_t size)
79 79
{
80 80
    MIPSnetState *s = opaque;
81 81

  
b/hw/musicpal.c
562 562
    return 1;
563 563
}
564 564

  
565
static void eth_receive(void *opaque, const uint8_t *buf, int size)
565
static void eth_receive(void *opaque, const uint8_t *buf, size_t size)
566 566
{
567 567
    mv88w8618_eth_state *s = opaque;
568 568
    uint32_t desc_addr;
b/hw/ne2000.c
224 224

  
225 225
#define MIN_BUF_SIZE 60
226 226

  
227
static void ne2000_receive(void *opaque, const uint8_t *buf, int size)
227
static void ne2000_receive(void *opaque, const uint8_t *buf, size_t size)
228 228
{
229 229
    NE2000State *s = opaque;
230 230
    uint8_t *p;
b/hw/pcnet.c
1076 1076

  
1077 1077
#define MIN_BUF_SIZE 60
1078 1078

  
1079
static void pcnet_receive(void *opaque, const uint8_t *buf, int size)
1079
static void pcnet_receive(void *opaque, const uint8_t *buf, size_t size)
1080 1080
{
1081 1081
    PCNetState *s = opaque;
1082 1082
    int is_padr = 0, is_bcast = 0, is_ladr = 0;
b/hw/qdev.c
258 258
}
259 259

  
260 260
VLANClientState *qdev_get_vlan_client(DeviceState *dev,
261
                                      IOCanRWHandler *fd_can_read,
262
                                      IOReadHandler *fd_read,
263
                                      IOReadvHandler *fd_readv,
261
                                      NetCanReceive *can_receive,
262
                                      NetReceive *receive,
263
                                      NetReceiveIOV *receive_iov,
264 264
                                      NetCleanup *cleanup,
265 265
                                      void *opaque)
266 266
{
267 267
    NICInfo *nd = dev->nd;
268 268
    assert(nd);
269
    return qemu_new_vlan_client(nd->vlan, nd->model, nd->name, fd_can_read,
270
                                fd_read, fd_readv, cleanup, opaque);
269
    return qemu_new_vlan_client(nd->vlan, nd->model, nd->name, can_receive,
270
                                receive, receive_iov, cleanup, opaque);
271 271
}
272 272

  
273 273

  
b/hw/rtl8139.c
1158 1158
    }
1159 1159
}
1160 1160

  
1161
static void rtl8139_receive(void *opaque, const uint8_t *buf, int size)
1161
static void rtl8139_receive(void *opaque, const uint8_t *buf, size_t size)
1162 1162
{
1163 1163
    rtl8139_do_receive(opaque, buf, size, 1);
1164 1164
}
b/hw/smc91c111.c
602 602
    return 1;
603 603
}
604 604

  
605
static void smc91c111_receive(void *opaque, const uint8_t *buf, int size)
605
static void smc91c111_receive(void *opaque, const uint8_t *buf, size_t size)
606 606
{
607 607
    smc91c111_state *s = (smc91c111_state *)opaque;
608 608
    int status;
b/hw/stellaris_enet.c
78 78
}
79 79

  
80 80
/* TODO: Implement MAC address filtering.  */
81
static void stellaris_enet_receive(void *opaque, const uint8_t *buf, int size)
81
static void stellaris_enet_receive(void *opaque, const uint8_t *buf, size_t size)
82 82
{
83 83
    stellaris_enet_state *s = (stellaris_enet_state *)opaque;
84 84
    int n;
b/hw/usb-net.c
1369 1369
    return ret;
1370 1370
}
1371 1371

  
1372
static void usbnet_receive(void *opaque, const uint8_t *buf, int size)
1372
static void usbnet_receive(void *opaque, const uint8_t *buf, size_t size)
1373 1373
{
1374 1374
    USBNetState *s = opaque;
1375 1375
    struct rndis_packet_msg_type *msg;
b/hw/virtio-net.c
361 361
    return 0;
362 362
}
363 363

  
364
static void virtio_net_receive(void *opaque, const uint8_t *buf, int size)
364
static void virtio_net_receive(void *opaque, const uint8_t *buf, size_t size)
365 365
{
366 366
    VirtIONet *n = opaque;
367 367
    struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL;
b/hw/xen_nic.c
243 243
    return 1;
244 244
}
245 245

  
246
static void net_rx_packet(void *opaque, const uint8_t *buf, int size)
246
static void net_rx_packet(void *opaque, const uint8_t *buf, size_t size)
247 247
{
248 248
    struct XenNetDev *netdev = opaque;
249 249
    netif_rx_request_t rxreq;
......
262 262
	return;
263 263
    }
264 264
    if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
265
	xen_be_printf(&netdev->xendev, 0, "packet too big (%d > %ld)",
266
		      size, XC_PAGE_SIZE - NET_IP_ALIGN);
265
	xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
266
		      (unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
267 267
	return;
268 268
    }
269 269

  
b/net.c
332 332
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
333 333
                                      const char *model,
334 334
                                      const char *name,
335
                                      IOCanRWHandler *fd_can_read,
336
                                      IOReadHandler *fd_read,
337
                                      IOReadvHandler *fd_readv,
335
                                      NetCanReceive *can_receive,
336
                                      NetReceive *receive,
337
                                      NetReceiveIOV *receive_iov,
338 338
                                      NetCleanup *cleanup,
339 339
                                      void *opaque)
340 340
{
......
345 345
        vc->name = strdup(name);
346 346
    else
347 347
        vc->name = assign_name(vc, model);
348
    vc->fd_can_read = fd_can_read;
349
    vc->fd_read = fd_read;
350
    vc->fd_readv = fd_readv;
348
    vc->can_receive = can_receive;
349
    vc->receive = receive;
350
    vc->receive_iov = receive_iov;
351 351
    vc->cleanup = cleanup;
352 352
    vc->opaque = opaque;
353 353
    vc->vlan = vlan;
......
401 401
            continue;
402 402
        }
403 403

  
404
        /* no fd_can_read() handler, they can always receive */
405
        if (!vc->fd_can_read || vc->fd_can_read(vc->opaque)) {
404
        /* no can_receive() handler, they can always receive */
405
        if (!vc->can_receive || vc->can_receive(vc->opaque)) {
406 406
            return 1;
407 407
        }
408 408
    }
......
416 416

  
417 417
    for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) {
418 418
        if (vc != sender && !vc->link_down) {
419
            vc->fd_read(vc->opaque, buf, size);
419
            vc->receive(vc->opaque, buf, size);
420 420
        }
421 421
    }
422 422
}
......
467 467
        offset += len;
468 468
    }
469 469

  
470
    vc->fd_read(vc->opaque, buffer, offset);
470
    vc->receive(vc->opaque, buffer, offset);
471 471

  
472 472
    return offset;
473 473
}
......
519 519
            }
520 520
            if (vc->link_down) {
521 521
                len = calc_iov_length(iov, iovcnt);
522
            } else if (vc->fd_readv) {
523
                len = vc->fd_readv(vc->opaque, iov, iovcnt);
524
            } else if (vc->fd_read) {
522
            } else if (vc->receive_iov) {
523
                len = vc->receive_iov(vc->opaque, iov, iovcnt);
524
            } else if (vc->receive) {
525 525
                len = vc_sendv_compat(vc, iov, iovcnt);
526 526
            }
527 527
            max_len = MAX(max_len, len);
......
593 593
    return slirp_inited;
594 594
}
595 595

  
596
static void slirp_receive(void *opaque, const uint8_t *buf, int size)
596
static void slirp_receive(void *opaque, const uint8_t *buf, size_t size)
597 597
{
598 598
#ifdef DEBUG_SLIRP
599 599
    printf("slirp input:\n");
......
945 945
    return len;
946 946
}
947 947

  
948
static void tap_receive(void *opaque, const uint8_t *buf, int size)
948
static void tap_receive(void *opaque, const uint8_t *buf, size_t size)
949 949
{
950 950
    TAPState *s = opaque;
951 951
    int ret;
......
1380 1380
} NetSocketListenState;
1381 1381

  
1382 1382
/* XXX: we consider we can send the whole packet without blocking */
1383
static void net_socket_receive(void *opaque, const uint8_t *buf, int size)
1383
static void net_socket_receive(void *opaque, const uint8_t *buf, size_t size)
1384 1384
{
1385 1385
    NetSocketState *s = opaque;
1386 1386
    uint32_t len;
......
1390 1390
    send_all(s->fd, buf, size);
1391 1391
}
1392 1392

  
1393
static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, int size)
1393
static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, size_t size)
1394 1394
{
1395 1395
    NetSocketState *s = opaque;
1396 1396
    sendto(s->fd, buf, size, 0,
......
1831 1831
    uint32_t len;
1832 1832
};
1833 1833

  
1834
static void dump_receive(void *opaque, const uint8_t *buf, int size)
1834
static void dump_receive(void *opaque, const uint8_t *buf, size_t size)
1835 1835
{
1836 1836
    DumpState *s = opaque;
1837 1837
    struct pcap_sf_pkthdr hdr;
b/net.h
5 5

  
6 6
/* VLANs support */
7 7

  
8
typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int);
9

  
10 8
typedef struct VLANClientState VLANClientState;
11 9

  
10
typedef int (NetCanReceive)(void *);
11
typedef void (NetReceive)(void *, const uint8_t *, size_t);
12
typedef ssize_t (NetReceiveIOV)(void *, const struct iovec *, int);
12 13
typedef void (NetCleanup) (VLANClientState *);
13 14
typedef void (LinkStatusChanged)(VLANClientState *);
14 15

  
15 16
struct VLANClientState {
16
    IOReadHandler *fd_read;
17
    IOReadvHandler *fd_readv;
17
    NetReceive *receive;
18
    NetReceiveIOV *receive_iov;
18 19
    /* Packets may still be sent if this returns zero.  It's used to
19 20
       rate-limit the slirp code.  */
20
    IOCanRWHandler *fd_can_read;
21
    NetCanReceive *can_receive;
21 22
    NetCleanup *cleanup;
22 23
    LinkStatusChanged *link_status_changed;
23 24
    int link_down;
......
51 52
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
52 53
                                      const char *model,
53 54
                                      const char *name,
54
                                      IOCanRWHandler *fd_can_read,
55
                                      IOReadHandler *fd_read,
56
                                      IOReadvHandler *fd_readv,
55
                                      NetCanReceive *can_receive,
56
                                      NetReceive *receive,
57
                                      NetReceiveIOV *receive_iov,
57 58
                                      NetCleanup *cleanup,
58 59
                                      void *opaque);
59 60
void qemu_del_vlan_client(VLANClientState *vc);
......
130 131

  
131 132
void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr);
132 133
VLANClientState *qdev_get_vlan_client(DeviceState *dev,
133
                                      IOCanRWHandler *fd_can_read,
134
                                      IOReadHandler *fd_read,
135
                                      IOReadvHandler *fd_readv,
134
                                      NetCanReceive *can_receive,
135
                                      NetReceive *receive,
136
                                      NetReceiveIOV *receive_iov,
136 137
                                      NetCleanup *cleanup,
137 138
                                      void *opaque);
138 139

  
b/savevm.c
131 131
        len = announce_self_create(buf, nd_table[i].macaddr);
132 132
        vlan = nd_table[i].vlan;
133 133
	for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
134
            vc->fd_read(vc->opaque, buf, len);
134
            vc->receive(vc->opaque, buf, len);
135 135
        }
136 136
    }
137 137
    if (count--) {
b/tap-win32.c
650 650
    qemu_free(s);
651 651
}
652 652

  
653
static void tap_receive(void *opaque, const uint8_t *buf, int size)
653
static void tap_receive(void *opaque, const uint8_t *buf, size_t size)
654 654
{
655 655
    TAPState *s = opaque;
656 656

  

Also available in: Unified diff