Give static type checking a chance to catch errors.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
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 */
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;
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;
}
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;
}
}
-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 };
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;
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;
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;
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;
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;
#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];
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;
#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;
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)
#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. */
}
}
-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;
}
}
-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)
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
{
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;
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;
}
/* 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;
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;
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) {
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) {
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;
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);
}
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;
#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)
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;
}
/* 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;
}
}
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);
}
}
}
offset += len;
}
- vc->receive(vc->opaque, buffer, offset);
+ vc->receive(vc, buffer, offset);
return offset;
}
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);
}
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");
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 {
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);
}
}
-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);
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",
} 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);
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));
}
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;
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 *);
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--) {
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;