Revision 806b6024 hw/usb-net.c
b/hw/usb-net.c | ||
---|---|---|
1432 | 1432 |
qemu_del_vlan_client(s->vc); |
1433 | 1433 |
} |
1434 | 1434 |
|
1435 |
USBDevice *usb_net_init(NICInfo *nd)
|
|
1435 |
static int usb_net_initfn(USBDevice *dev)
|
|
1436 | 1436 |
{ |
1437 |
USBNetState *s; |
|
1438 |
|
|
1439 |
s = qemu_mallocz(sizeof(USBNetState)); |
|
1440 |
s->dev.speed = USB_SPEED_FULL; |
|
1441 |
s->dev.handle_packet = usb_generic_handle_packet; |
|
1437 |
USBNetState *s = DO_UPCAST(USBNetState, dev, dev); |
|
1442 | 1438 |
|
1443 |
s->dev.handle_reset = usb_net_handle_reset; |
|
1444 |
s->dev.handle_control = usb_net_handle_control; |
|
1445 |
s->dev.handle_data = usb_net_handle_data; |
|
1446 |
s->dev.handle_destroy = usb_net_handle_destroy; |
|
1439 |
s->dev.speed = USB_SPEED_FULL; |
|
1447 | 1440 |
|
1448 | 1441 |
s->rndis = 1; |
1449 | 1442 |
s->rndis_state = RNDIS_UNINITIALIZED; |
1443 |
TAILQ_INIT(&s->rndis_resp); |
|
1444 |
|
|
1450 | 1445 |
s->medium = 0; /* NDIS_MEDIUM_802_3 */ |
1451 | 1446 |
s->speed = 1000000; /* 100MBps, in 100Bps units */ |
1452 | 1447 |
s->media_state = 0; /* NDIS_MEDIA_STATE_CONNECTED */; |
1453 | 1448 |
s->filter = 0; |
1454 | 1449 |
s->vendorid = 0x1234; |
1450 |
return 0; |
|
1451 |
} |
|
1452 |
|
|
1453 |
USBDevice *usb_net_init(NICInfo *nd) |
|
1454 |
{ |
|
1455 |
USBDevice *dev; |
|
1456 |
USBNetState *s; |
|
1457 |
|
|
1458 |
dev = usb_create_simple(NULL /* FIXME */, "QEMU USB Network Interface"); |
|
1459 |
s = DO_UPCAST(USBNetState, dev, dev); |
|
1455 | 1460 |
|
1456 | 1461 |
memcpy(s->mac, nd->macaddr, 6); |
1457 |
TAILQ_INIT(&s->rndis_resp); |
|
1458 | 1462 |
|
1459 |
pstrcpy(s->dev.devname, sizeof(s->dev.devname), |
|
1460 |
"QEMU USB Network Interface"); |
|
1461 | 1463 |
s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, |
1462 | 1464 |
usbnet_can_receive, |
1463 | 1465 |
usbnet_receive, |
... | ... | |
1476 | 1478 |
|
1477 | 1479 |
return (USBDevice *) s; |
1478 | 1480 |
} |
1481 |
|
|
1482 |
static struct USBDeviceInfo net_info = { |
|
1483 |
.qdev.name = "QEMU USB Network Interface", |
|
1484 |
.qdev.size = sizeof(USBNetState), |
|
1485 |
.init = usb_net_initfn, |
|
1486 |
.handle_packet = usb_generic_handle_packet, |
|
1487 |
.handle_reset = usb_net_handle_reset, |
|
1488 |
.handle_control = usb_net_handle_control, |
|
1489 |
.handle_data = usb_net_handle_data, |
|
1490 |
.handle_destroy = usb_net_handle_destroy, |
|
1491 |
}; |
|
1492 |
|
|
1493 |
static void usb_net_register_devices(void) |
|
1494 |
{ |
|
1495 |
usb_qdev_register(&net_info); |
|
1496 |
} |
|
1497 |
device_init(usb_net_register_devices) |
Also available in: Unified diff