aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-net.c
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-05-18 13:40:55 +0100
committerMark McLoughlin <markmc@redhat.com>2009-06-09 11:38:49 +0100
commit4f1c942b7fb29864ad86cb3af9076da38f38f74e (patch)
tree2f51a121e715476c3986c0ae0b4513be555d8ee8 /hw/usb-net.c
parente3f5ec2b5e92706e3b807059f79b1fb5d936e567 (diff)
downloadqemu-4f1c942b7fb29864ad86cb3af9076da38f38f74e.zip
qemu-4f1c942b7fb29864ad86cb3af9076da38f38f74e.tar.gz
qemu-4f1c942b7fb29864ad86cb3af9076da38f38f74e.tar.bz2
net: add return value to packet receive handler
This allows us to handle queue full conditions rather than dropping the packet on the floor. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Diffstat (limited to 'hw/usb-net.c')
-rw-r--r--hw/usb-net.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/hw/usb-net.c b/hw/usb-net.c
index d8d5e77..0e80ca6 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1369,7 +1369,7 @@ static int usb_net_handle_data(USBDevice *dev, USBPacket *p)
return ret;
}
-static void usbnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
+static ssize_t usbnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
USBNetState *s = vc->opaque;
struct rndis_packet_msg_type *msg;
@@ -1377,9 +1377,9 @@ static void usbnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
if (s->rndis) {
msg = (struct rndis_packet_msg_type *) s->in_buf;
if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
- return;
+ return -1;
if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
- return;
+ return -1;
memset(msg, 0, sizeof(struct rndis_packet_msg_type));
msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);
@@ -1398,11 +1398,12 @@ static void usbnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
s->in_len = size + sizeof(struct rndis_packet_msg_type);
} else {
if (size > sizeof(s->in_buf))
- return;
+ return -1;
memcpy(s->in_buf, buf, size);
s->in_len = size;
}
s->in_ptr = 0;
+ return size;
}
static int usbnet_can_receive(VLANClientState *vc)