uint8_t *inbuf, unsigned int inlen, uint8_t *outbuf,
size_t outlen)
{
- unsigned int i, count;
+ unsigned int i;
switch (oid) {
/* general oids (table 4-1) */
/* mandatory */
case OID_GEN_SUPPORTED_LIST:
- count = sizeof(oid_supported_list) / sizeof(uint32_t);
- for (i = 0; i < count; i++)
+ for (i = 0; i < ARRAY_SIZE(oid_supported_list); i++)
((le32 *) outbuf)[i] = cpu_to_le32(oid_supported_list[i]);
return sizeof(oid_supported_list);
/* mandatory */
case OID_GEN_VENDOR_DESCRIPTION:
- pstrcpy(outbuf, outlen, "QEMU USB RNDIS Net");
- return strlen(outbuf) + 1;
+ pstrcpy((char *)outbuf, outlen, "QEMU USB RNDIS Net");
+ return strlen((char *)outbuf) + 1;
case OID_GEN_VENDOR_DRIVER_VERSION:
*((le32 *) outbuf) = cpu_to_le32(1);
return !s->in_len;
}
+static void usbnet_cleanup(VLANClientState *vc)
+{
+ USBNetState *s = vc->opaque;
+
+ rndis_clear_responsequeue(s);
+ qemu_free(s);
+}
+
static void usb_net_handle_destroy(USBDevice *dev)
{
USBNetState *s = (USBNetState *) dev;
/* TODO: remove the nd_table[] entry */
qemu_del_vlan_client(s->vc);
- rndis_clear_responsequeue(s);
- qemu_free(s);
}
USBDevice *usb_net_init(NICInfo *nd)
USBNetState *s;
s = qemu_mallocz(sizeof(USBNetState));
- if (!s)
- return NULL;
s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet;
pstrcpy(s->dev.devname, sizeof(s->dev.devname),
"QEMU USB Network Interface");
- s->vc = qemu_new_vlan_client(nd->vlan,
- usbnet_receive, usbnet_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+ usbnet_receive,
+ usbnet_can_receive,
+ usbnet_cleanup, s);
+
+ qemu_format_nic_info_str(s->vc, s->mac);
snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
"%02x%02x%02x%02x%02x%02x",
0x40, s->mac[1], s->mac[2],
s->mac[3], s->mac[4], s->mac[5]);
- snprintf(s->vc->info_str, sizeof(s->vc->info_str),
- "usbnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
- s->mac[0], s->mac[1], s->mac[2],
- s->mac[3], s->mac[4], s->mac[5]);
fprintf(stderr, "usbnet: initialized mac %02x:%02x:%02x:%02x:%02x:%02x\n",
s->mac[0], s->mac[1], s->mac[2],
s->mac[3], s->mac[4], s->mac[5]);