static void usbredir_cancel_packet(USBDevice *udev, USBPacket *p)
{
    USBRedirDevice *dev = USB_REDIRECT(udev);
    int i = USBEP2I(p->ep);

    if (p->combined) {
        usb_combined_packet_cancel(udev, p);
        return;
    }

    if (dev->endpoint[i].pending_async_packet) {
        assert(dev->endpoint[i].pending_async_packet == p);
        dev->endpoint[i].pending_async_packet = NULL;
        return;
    }

    packet_id_queue_add(&dev->cancelled, p->id);
    usbredirparser_send_cancel_data_packet(dev->parser, p->id);
    usbredirparser_do_write(dev->parser);
}
static void usbredir_cancel_packet(USBDevice *udev, USBPacket *p)
{
    USBRedirDevice *dev = USB_REDIRECT(udev);
    int i = USBEP2I(p->ep);

    if (p->combined) {
        usb_combined_packet_cancel(udev, p);
        return;
    }

    if (dev->endpoint[i].pending_async_packet) {
        assert(dev->endpoint[i].pending_async_packet == p);
        dev->endpoint[i].pending_async_packet = NULL;
        return;
    }

    packet_id_queue_add(&dev->cancelled, p->id);
    usbredirparser_send_cancel_data_packet(dev->parser, p->id);
    usbredirparser_do_write(dev->parser);
}