net: pass VLANClientState* as first arg to receive handlers
Give static type checking a chance to catch errors. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
This commit is contained in:
parent
cda9046ba7
commit
e3f5ec2b5e
12
hw/dp8393x.c
12
hw/dp8393x.c
@ -407,9 +407,9 @@ static void do_transmit_packets(dp8393xState *s)
|
||||
if (s->regs[SONIC_RCR] & (SONIC_RCR_LB1 | SONIC_RCR_LB0)) {
|
||||
/* Loopback */
|
||||
s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
|
||||
if (s->vc->fd_can_read(s)) {
|
||||
if (s->vc->can_receive(s->vc)) {
|
||||
s->loopback_packet = 1;
|
||||
s->vc->receive(s, s->tx_buffer, tx_len);
|
||||
s->vc->receive(s->vc, s->tx_buffer, tx_len);
|
||||
}
|
||||
} else {
|
||||
/* Transmit packet */
|
||||
@ -676,9 +676,9 @@ static CPUWriteMemoryFunc *dp8393x_write[3] = {
|
||||
dp8393x_writel,
|
||||
};
|
||||
|
||||
static int nic_can_receive(void *opaque)
|
||||
static int nic_can_receive(VLANClientState *vc)
|
||||
{
|
||||
dp8393xState *s = opaque;
|
||||
dp8393xState *s = vc->opaque;
|
||||
|
||||
if (!(s->regs[SONIC_CR] & SONIC_CR_RXEN))
|
||||
return 0;
|
||||
@ -725,10 +725,10 @@ static int receive_filter(dp8393xState *s, const uint8_t * buf, int size)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void nic_receive(void *opaque, const uint8_t * buf, size_t size)
|
||||
static void nic_receive(VLANClientState *vc, const uint8_t * buf, size_t size)
|
||||
{
|
||||
uint16_t data[10];
|
||||
dp8393xState *s = opaque;
|
||||
dp8393xState *s = vc->opaque;
|
||||
int packet_type;
|
||||
uint32_t available, address;
|
||||
int width, rx_len = size;
|
||||
|
@ -592,17 +592,17 @@ e1000_set_link_status(VLANClientState *vc)
|
||||
}
|
||||
|
||||
static int
|
||||
e1000_can_receive(void *opaque)
|
||||
e1000_can_receive(VLANClientState *vc)
|
||||
{
|
||||
E1000State *s = opaque;
|
||||
E1000State *s = vc->opaque;
|
||||
|
||||
return (s->mac_reg[RCTL] & E1000_RCTL_EN);
|
||||
}
|
||||
|
||||
static void
|
||||
e1000_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
e1000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
E1000State *s = opaque;
|
||||
E1000State *s = vc->opaque;
|
||||
struct e1000_rx_desc desc;
|
||||
target_phys_addr_t base;
|
||||
unsigned int n, rdt;
|
||||
|
@ -1433,21 +1433,21 @@ static void pci_mmio_map(PCIDevice * pci_dev, int region_num,
|
||||
}
|
||||
}
|
||||
|
||||
static int nic_can_receive(void *opaque)
|
||||
static int nic_can_receive(VLANClientState *vc)
|
||||
{
|
||||
EEPRO100State *s = opaque;
|
||||
EEPRO100State *s = vc->opaque;
|
||||
logout("%p\n", s);
|
||||
return get_ru_state(s) == ru_ready;
|
||||
//~ return !eepro100_buffer_full(s);
|
||||
}
|
||||
|
||||
static void nic_receive(void *opaque, const uint8_t * buf, size_t size)
|
||||
static void nic_receive(VLANClientState *vc, const uint8_t * buf, size_t size)
|
||||
{
|
||||
/* TODO:
|
||||
* - Magic packets should set bit 30 in power management driver register.
|
||||
* - Interesting packets should set bit 29 in power management driver register.
|
||||
*/
|
||||
EEPRO100State *s = opaque;
|
||||
EEPRO100State *s = vc->opaque;
|
||||
uint16_t rfd_status = 0xa000;
|
||||
static const uint8_t broadcast_macaddr[6] =
|
||||
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
|
@ -496,15 +496,15 @@ static int eth_match_groupaddr(struct fs_eth *eth, const unsigned char *sa)
|
||||
return match;
|
||||
}
|
||||
|
||||
static int eth_can_receive(void *opaque)
|
||||
static int eth_can_receive(VLANClientState *vc)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void eth_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
unsigned char sa_bcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
struct fs_eth *eth = opaque;
|
||||
struct fs_eth *eth = vc->opaque;
|
||||
int use_ma0 = eth->regs[RW_REC_CTRL] & 1;
|
||||
int use_ma1 = eth->regs[RW_REC_CTRL] & 2;
|
||||
int r_bcast = eth->regs[RW_REC_CTRL] & 8;
|
||||
|
@ -347,15 +347,15 @@ static void mcf_fec_write(void *opaque, target_phys_addr_t addr, uint32_t value)
|
||||
mcf_fec_update(s);
|
||||
}
|
||||
|
||||
static int mcf_fec_can_receive(void *opaque)
|
||||
static int mcf_fec_can_receive(VLANClientState *vc)
|
||||
{
|
||||
mcf_fec_state *s = (mcf_fec_state *)opaque;
|
||||
mcf_fec_state *s = vc->opaque;
|
||||
return s->rx_enabled;
|
||||
}
|
||||
|
||||
static void mcf_fec_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void mcf_fec_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
mcf_fec_state *s = (mcf_fec_state *)opaque;
|
||||
mcf_fec_state *s = vc->opaque;
|
||||
mcf_fec_bd bd;
|
||||
uint32_t flags = 0;
|
||||
uint32_t addr;
|
||||
|
10
hw/mipsnet.c
10
hw/mipsnet.c
@ -66,23 +66,23 @@ static int mipsnet_buffer_full(MIPSnetState *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mipsnet_can_receive(void *opaque)
|
||||
static int mipsnet_can_receive(VLANClientState *vc)
|
||||
{
|
||||
MIPSnetState *s = opaque;
|
||||
MIPSnetState *s = vc->opaque;
|
||||
|
||||
if (s->busy)
|
||||
return 0;
|
||||
return !mipsnet_buffer_full(s);
|
||||
}
|
||||
|
||||
static void mipsnet_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void mipsnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
MIPSnetState *s = opaque;
|
||||
MIPSnetState *s = vc->opaque;
|
||||
|
||||
#ifdef DEBUG_MIPSNET_RECEIVE
|
||||
printf("mipsnet: receiving len=%d\n", size);
|
||||
#endif
|
||||
if (!mipsnet_can_receive(opaque))
|
||||
if (!mipsnet_can_receive(vc))
|
||||
return;
|
||||
|
||||
s->busy = 1;
|
||||
|
@ -557,14 +557,14 @@ static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc)
|
||||
le32_to_cpus(&desc->next);
|
||||
}
|
||||
|
||||
static int eth_can_receive(void *opaque)
|
||||
static int eth_can_receive(VLANClientState *vc)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void eth_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
mv88w8618_eth_state *s = opaque;
|
||||
mv88w8618_eth_state *s = vc->opaque;
|
||||
uint32_t desc_addr;
|
||||
mv88w8618_rx_desc desc;
|
||||
int i;
|
||||
|
@ -213,9 +213,9 @@ static int ne2000_buffer_full(NE2000State *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ne2000_can_receive(void *opaque)
|
||||
static int ne2000_can_receive(VLANClientState *vc)
|
||||
{
|
||||
NE2000State *s = opaque;
|
||||
NE2000State *s = vc->opaque;
|
||||
|
||||
if (s->cmd & E8390_STOP)
|
||||
return 1;
|
||||
@ -224,9 +224,9 @@ static int ne2000_can_receive(void *opaque)
|
||||
|
||||
#define MIN_BUF_SIZE 60
|
||||
|
||||
static void ne2000_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
NE2000State *s = opaque;
|
||||
NE2000State *s = vc->opaque;
|
||||
uint8_t *p;
|
||||
unsigned int total_len, next, avail, len, index, mcast_idx;
|
||||
uint8_t buf1[60];
|
||||
|
10
hw/pcnet.c
10
hw/pcnet.c
@ -1062,9 +1062,9 @@ static int pcnet_tdte_poll(PCNetState *s)
|
||||
return !!(CSR_CXST(s) & 0x8000);
|
||||
}
|
||||
|
||||
static int pcnet_can_receive(void *opaque)
|
||||
static int pcnet_can_receive(VLANClientState *vc)
|
||||
{
|
||||
PCNetState *s = opaque;
|
||||
PCNetState *s = vc->opaque;
|
||||
if (CSR_STOP(s) || CSR_SPND(s))
|
||||
return 0;
|
||||
|
||||
@ -1076,9 +1076,9 @@ static int pcnet_can_receive(void *opaque)
|
||||
|
||||
#define MIN_BUF_SIZE 60
|
||||
|
||||
static void pcnet_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void pcnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
PCNetState *s = opaque;
|
||||
PCNetState *s = vc->opaque;
|
||||
int is_padr = 0, is_bcast = 0, is_ladr = 0;
|
||||
uint8_t buf1[60];
|
||||
int remaining;
|
||||
@ -1302,7 +1302,7 @@ static void pcnet_transmit(PCNetState *s)
|
||||
if (BCR_SWSTYLE(s) == 1)
|
||||
add_crc = !GET_FIELD(tmd.status, TMDS, NOFCS);
|
||||
s->looptest = add_crc ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC;
|
||||
pcnet_receive(s, s->buffer, s->xmit_pos);
|
||||
pcnet_receive(s->vc, s->buffer, s->xmit_pos);
|
||||
s->looptest = 0;
|
||||
} else
|
||||
if (s->vc)
|
||||
|
14
hw/rtl8139.c
14
hw/rtl8139.c
@ -790,9 +790,9 @@ static inline target_phys_addr_t rtl8139_addr64(uint32_t low, uint32_t high)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int rtl8139_can_receive(void *opaque)
|
||||
static int rtl8139_can_receive(VLANClientState *vc)
|
||||
{
|
||||
RTL8139State *s = opaque;
|
||||
RTL8139State *s = vc->opaque;
|
||||
int avail;
|
||||
|
||||
/* Receive (drop) packets if card is disabled. */
|
||||
@ -812,9 +812,9 @@ static int rtl8139_can_receive(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
static void rtl8139_do_receive(void *opaque, const uint8_t *buf, int size, int do_interrupt)
|
||||
static void rtl8139_do_receive(VLANClientState *vc, const uint8_t *buf, int size, int do_interrupt)
|
||||
{
|
||||
RTL8139State *s = opaque;
|
||||
RTL8139State *s = vc->opaque;
|
||||
|
||||
uint32_t packet_header = 0;
|
||||
|
||||
@ -1158,9 +1158,9 @@ static void rtl8139_do_receive(void *opaque, const uint8_t *buf, int size, int d
|
||||
}
|
||||
}
|
||||
|
||||
static void rtl8139_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void rtl8139_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
rtl8139_do_receive(opaque, buf, size, 1);
|
||||
rtl8139_do_receive(vc, buf, size, 1);
|
||||
}
|
||||
|
||||
static void rtl8139_reset_rxring(RTL8139State *s, uint32_t bufferSize)
|
||||
@ -1757,7 +1757,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, const uint8_t *buf, int size
|
||||
if (TxLoopBack == (s->TxConfig & TxLoopBack))
|
||||
{
|
||||
DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
|
||||
rtl8139_do_receive(s, buf, size, do_interrupt);
|
||||
rtl8139_do_receive(s->vc, buf, size, do_interrupt);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -591,9 +591,9 @@ static uint32_t smc91c111_readl(void *opaque, target_phys_addr_t offset)
|
||||
return val;
|
||||
}
|
||||
|
||||
static int smc91c111_can_receive(void *opaque)
|
||||
static int smc91c111_can_receive(VLANClientState *vc)
|
||||
{
|
||||
smc91c111_state *s = (smc91c111_state *)opaque;
|
||||
smc91c111_state *s = vc->opaque;
|
||||
|
||||
if ((s->rcr & RCR_RXEN) == 0 || (s->rcr & RCR_SOFT_RST))
|
||||
return 1;
|
||||
@ -602,9 +602,9 @@ static int smc91c111_can_receive(void *opaque)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void smc91c111_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void smc91c111_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
smc91c111_state *s = (smc91c111_state *)opaque;
|
||||
smc91c111_state *s = vc->opaque;
|
||||
int status;
|
||||
int packetsize;
|
||||
uint32_t crc;
|
||||
|
@ -78,9 +78,9 @@ static void stellaris_enet_update(stellaris_enet_state *s)
|
||||
}
|
||||
|
||||
/* TODO: Implement MAC address filtering. */
|
||||
static void stellaris_enet_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void stellaris_enet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
stellaris_enet_state *s = (stellaris_enet_state *)opaque;
|
||||
stellaris_enet_state *s = vc->opaque;
|
||||
int n;
|
||||
uint8_t *p;
|
||||
uint32_t crc;
|
||||
@ -118,9 +118,9 @@ static void stellaris_enet_receive(void *opaque, const uint8_t *buf, size_t size
|
||||
stellaris_enet_update(s);
|
||||
}
|
||||
|
||||
static int stellaris_enet_can_receive(void *opaque)
|
||||
static int stellaris_enet_can_receive(VLANClientState *vc)
|
||||
{
|
||||
stellaris_enet_state *s = (stellaris_enet_state *)opaque;
|
||||
stellaris_enet_state *s = vc->opaque;
|
||||
|
||||
if ((s->rctl & SE_RCTL_RXEN) == 0)
|
||||
return 1;
|
||||
@ -128,9 +128,9 @@ static int stellaris_enet_can_receive(void *opaque)
|
||||
return (s->np < 31);
|
||||
}
|
||||
|
||||
static uint32_t stellaris_enet_read(void *opaque, target_phys_addr_t offset)
|
||||
static uint32_t stellaris_enet_read(VLANClientState *vc, target_phys_addr_t offset)
|
||||
{
|
||||
stellaris_enet_state *s = (stellaris_enet_state *)opaque;
|
||||
stellaris_enet_state *s = vc->opaque;
|
||||
uint32_t val;
|
||||
|
||||
switch (offset) {
|
||||
|
@ -1369,9 +1369,9 @@ static int usb_net_handle_data(USBDevice *dev, USBPacket *p)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void usbnet_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void usbnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
USBNetState *s = opaque;
|
||||
USBNetState *s = vc->opaque;
|
||||
struct rndis_packet_msg_type *msg;
|
||||
|
||||
if (s->rndis) {
|
||||
@ -1405,9 +1405,9 @@ static void usbnet_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
s->in_ptr = 0;
|
||||
}
|
||||
|
||||
static int usbnet_can_receive(void *opaque)
|
||||
static int usbnet_can_receive(VLANClientState *vc)
|
||||
{
|
||||
USBNetState *s = opaque;
|
||||
USBNetState *s = vc->opaque;
|
||||
|
||||
if (s->rndis && !s->rndis_state == RNDIS_DATA_INITIALIZED)
|
||||
return 1;
|
||||
|
@ -288,9 +288,9 @@ static int do_virtio_net_can_receive(VirtIONet *n, int bufsize)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int virtio_net_can_receive(void *opaque)
|
||||
static int virtio_net_can_receive(VLANClientState *vc)
|
||||
{
|
||||
VirtIONet *n = opaque;
|
||||
VirtIONet *n = vc->opaque;
|
||||
|
||||
return do_virtio_net_can_receive(n, VIRTIO_NET_MAX_BUFSIZE);
|
||||
}
|
||||
@ -361,9 +361,9 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void virtio_net_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void virtio_net_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
VirtIONet *n = opaque;
|
||||
VirtIONet *n = vc->opaque;
|
||||
struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL;
|
||||
size_t hdr_len, offset, i;
|
||||
|
||||
|
@ -223,9 +223,9 @@ static void net_rx_response(struct XenNetDev *netdev,
|
||||
|
||||
#define NET_IP_ALIGN 2
|
||||
|
||||
static int net_rx_ok(void *opaque)
|
||||
static int net_rx_ok(VLANClientState *vc)
|
||||
{
|
||||
struct XenNetDev *netdev = opaque;
|
||||
struct XenNetDev *netdev = vc->opaque;
|
||||
RING_IDX rc, rp;
|
||||
|
||||
if (netdev->xendev.be_state != XenbusStateConnected)
|
||||
@ -243,9 +243,9 @@ static int net_rx_ok(void *opaque)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void net_rx_packet(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void net_rx_packet(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
struct XenNetDev *netdev = opaque;
|
||||
struct XenNetDev *netdev = vc->opaque;
|
||||
netif_rx_request_t rxreq;
|
||||
RING_IDX rc, rp;
|
||||
void *page;
|
||||
|
36
net.c
36
net.c
@ -402,7 +402,7 @@ int qemu_can_send_packet(VLANClientState *sender)
|
||||
}
|
||||
|
||||
/* no can_receive() handler, they can always receive */
|
||||
if (!vc->can_receive || vc->can_receive(vc->opaque)) {
|
||||
if (!vc->can_receive || vc->can_receive(vc)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -416,7 +416,7 @@ qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size)
|
||||
|
||||
for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) {
|
||||
if (vc != sender && !vc->link_down) {
|
||||
vc->receive(vc->opaque, buf, size);
|
||||
vc->receive(vc, buf, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -467,7 +467,7 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov,
|
||||
offset += len;
|
||||
}
|
||||
|
||||
vc->receive(vc->opaque, buffer, offset);
|
||||
vc->receive(vc, buffer, offset);
|
||||
|
||||
return offset;
|
||||
}
|
||||
@ -520,7 +520,7 @@ ssize_t qemu_sendv_packet(VLANClientState *sender, const struct iovec *iov,
|
||||
if (vc->link_down) {
|
||||
len = calc_iov_length(iov, iovcnt);
|
||||
} else if (vc->receive_iov) {
|
||||
len = vc->receive_iov(vc->opaque, iov, iovcnt);
|
||||
len = vc->receive_iov(vc, iov, iovcnt);
|
||||
} else if (vc->receive) {
|
||||
len = vc_sendv_compat(vc, iov, iovcnt);
|
||||
}
|
||||
@ -593,7 +593,7 @@ int slirp_is_inited(void)
|
||||
return slirp_inited;
|
||||
}
|
||||
|
||||
static void slirp_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void slirp_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
#ifdef DEBUG_SLIRP
|
||||
printf("slirp input:\n");
|
||||
@ -932,10 +932,10 @@ typedef struct TAPState {
|
||||
|
||||
static int launch_script(const char *setup_script, const char *ifname, int fd);
|
||||
|
||||
static ssize_t tap_receive_iov(void *opaque, const struct iovec *iov,
|
||||
static ssize_t tap_receive_iov(VLANClientState *vc, const struct iovec *iov,
|
||||
int iovcnt)
|
||||
{
|
||||
TAPState *s = opaque;
|
||||
TAPState *s = vc->opaque;
|
||||
ssize_t len;
|
||||
|
||||
do {
|
||||
@ -945,9 +945,9 @@ static ssize_t tap_receive_iov(void *opaque, const struct iovec *iov,
|
||||
return len;
|
||||
}
|
||||
|
||||
static void tap_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void tap_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
TAPState *s = opaque;
|
||||
TAPState *s = vc->opaque;
|
||||
int ret;
|
||||
for(;;) {
|
||||
ret = write(s->fd, buf, size);
|
||||
@ -1311,9 +1311,9 @@ static void vde_to_qemu(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
static void vde_from_qemu(void *opaque, const uint8_t *buf, int size)
|
||||
static void vde_receive(VLANClientState *vc, const uint8_t *buf, int size)
|
||||
{
|
||||
VDEState *s = opaque;
|
||||
VDEState *s = vc->opaque;
|
||||
int ret;
|
||||
for(;;) {
|
||||
ret = vde_send(s->vde, (const char *)buf, size, 0);
|
||||
@ -1352,7 +1352,7 @@ static int net_vde_init(VLANState *vlan, const char *model,
|
||||
free(s);
|
||||
return -1;
|
||||
}
|
||||
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, vde_from_qemu,
|
||||
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, vde_receive,
|
||||
NULL, vde_cleanup, s);
|
||||
qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
|
||||
snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d",
|
||||
@ -1380,9 +1380,9 @@ typedef struct NetSocketListenState {
|
||||
} NetSocketListenState;
|
||||
|
||||
/* XXX: we consider we can send the whole packet without blocking */
|
||||
static void net_socket_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void net_socket_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
NetSocketState *s = opaque;
|
||||
NetSocketState *s = vc->opaque;
|
||||
uint32_t len;
|
||||
len = htonl(size);
|
||||
|
||||
@ -1390,9 +1390,9 @@ static void net_socket_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
send_all(s->fd, buf, size);
|
||||
}
|
||||
|
||||
static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void net_socket_receive_dgram(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
NetSocketState *s = opaque;
|
||||
NetSocketState *s = vc->opaque;
|
||||
sendto(s->fd, buf, size, 0,
|
||||
(struct sockaddr *)&s->dgram_dst, sizeof(s->dgram_dst));
|
||||
}
|
||||
@ -1831,9 +1831,9 @@ struct pcap_sf_pkthdr {
|
||||
uint32_t len;
|
||||
};
|
||||
|
||||
static void dump_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void dump_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
DumpState *s = opaque;
|
||||
DumpState *s = vc->opaque;
|
||||
struct pcap_sf_pkthdr hdr;
|
||||
int64_t ts;
|
||||
int caplen;
|
||||
|
6
net.h
6
net.h
@ -7,9 +7,9 @@
|
||||
|
||||
typedef struct VLANClientState VLANClientState;
|
||||
|
||||
typedef int (NetCanReceive)(void *);
|
||||
typedef void (NetReceive)(void *, const uint8_t *, size_t);
|
||||
typedef ssize_t (NetReceiveIOV)(void *, const struct iovec *, int);
|
||||
typedef int (NetCanReceive)(VLANClientState *);
|
||||
typedef void (NetReceive)(VLANClientState *, const uint8_t *, size_t);
|
||||
typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int);
|
||||
typedef void (NetCleanup) (VLANClientState *);
|
||||
typedef void (LinkStatusChanged)(VLANClientState *);
|
||||
|
||||
|
2
savevm.c
2
savevm.c
@ -131,7 +131,7 @@ static void qemu_announce_self_once(void *opaque)
|
||||
len = announce_self_create(buf, nd_table[i].macaddr);
|
||||
vlan = nd_table[i].vlan;
|
||||
for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
|
||||
vc->receive(vc->opaque, buf, len);
|
||||
vc->receive(vc, buf, len);
|
||||
}
|
||||
}
|
||||
if (count--) {
|
||||
|
@ -650,7 +650,7 @@ static void tap_cleanup(VLANClientState *vc)
|
||||
qemu_free(s);
|
||||
}
|
||||
|
||||
static void tap_receive(void *opaque, const uint8_t *buf, size_t size)
|
||||
static void tap_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
||||
{
|
||||
TAPState *s = opaque;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user