static int usbredir_alloc_streams(USBDevice *udev, USBEndpoint **eps,
                                  int nr_eps, int streams)
{
    USBRedirDevice *dev = USB_REDIRECT(udev);
#if USBREDIR_VERSION >= 0x000700
    struct usb_redir_alloc_bulk_streams_header alloc_streams;
    int i;

    if (!usbredirparser_peer_has_cap(dev->parser,
                                     usb_redir_cap_bulk_streams)) {
        ERROR("peer does not support streams\n");
        goto reject;
    }

    if (streams == 0) {
        ERROR("request to allocate 0 streams\n");
        return -1;
    }

    alloc_streams.no_streams = streams;
    alloc_streams.endpoints = 0;
    for (i = 0; i < nr_eps; i++) {
        alloc_streams.endpoints |= 1 << USBEP2I(eps[i]);
    }
    usbredirparser_send_alloc_bulk_streams(dev->parser, 0, &alloc_streams);
    usbredirparser_do_write(dev->parser);

    return 0;
#else
    ERROR("usbredir_alloc_streams not implemented\n");
    goto reject;
#endif
reject:
    ERROR("streams are not available, disconnecting\n");
    qemu_bh_schedule(dev->device_reject_bh);
    return -1;
}
static int usbredir_alloc_streams(USBDevice *udev, USBEndpoint **eps,
                                  int nr_eps, int streams)
{
    USBRedirDevice *dev = USB_REDIRECT(udev);
#if USBREDIR_VERSION >= 0x000700
    struct usb_redir_alloc_bulk_streams_header alloc_streams;
    int i;

    if (!usbredirparser_peer_has_cap(dev->parser,
                                     usb_redir_cap_bulk_streams)) {
        ERROR("peer does not support streams\n");
        goto reject;
    }

    if (streams == 0) {
        ERROR("request to allocate 0 streams\n");
        return -1;
    }

    alloc_streams.no_streams = streams;
    alloc_streams.endpoints = 0;
    for (i = 0; i < nr_eps; i++) {
        alloc_streams.endpoints |= 1 << USBEP2I(eps[i]);
    }
    usbredirparser_send_alloc_bulk_streams(dev->parser, 0, &alloc_streams);
    usbredirparser_do_write(dev->parser);

    return 0;
#else
    ERROR("usbredir_alloc_streams not implemented\n");
    goto reject;
#endif
reject:
    ERROR("streams are not available, disconnecting\n");
    qemu_bh_schedule(dev->device_reject_bh);
    return -1;
}