static void usbredir_bulk_packet(void *priv, uint32_t id,

    struct usb_redir_bulk_packet_header *bulk_packet,

    uint8_t *data, int data_len)

{

    USBRedirDevice *dev = priv;

    uint8_t ep = bulk_packet->endpoint;

    int len = bulk_packet->length;

    AsyncURB *aurb;



    DPRINTF("bulk-in status %d ep %02X len %d id %u\n", bulk_packet->status,

            ep, len, id);



    aurb = async_find(dev, id);

    if (!aurb) {

        free(data);

        return;

    }



    if (aurb->bulk_packet.endpoint != bulk_packet->endpoint ||

            aurb->bulk_packet.stream_id != bulk_packet->stream_id) {

        ERROR("return bulk packet mismatch, please report this!\n");

        len = USB_RET_NAK;

    }



    if (aurb->packet) {

        len = usbredir_handle_status(dev, bulk_packet->status, len);

        if (len > 0) {

            usbredir_log_data(dev, "bulk data in:", data, data_len);

            if (data_len <= aurb->packet->len) {

                memcpy(aurb->packet->data, data, data_len);

            } else {

                ERROR("bulk buffer too small (%d > %d)\n", data_len,

                      aurb->packet->len);

                len = USB_RET_STALL;

            }

        }

        aurb->packet->len = len;

        usb_packet_complete(&dev->dev, aurb->packet);

    }

    async_free(dev, aurb);

    free(data);

}

static void usbredir_bulk_packet(void *priv, uint32_t id,

    struct usb_redir_bulk_packet_header *bulk_packet,

    uint8_t *data, int data_len)

{

    USBRedirDevice *dev = priv;

    uint8_t ep = bulk_packet->endpoint;

    int len = bulk_packet->length;

    AsyncURB *aurb;



    DPRINTF("bulk-in status %d ep %02X len %d id %u\n", bulk_packet->status,

            ep, len, id);



    aurb = async_find(dev, id);

    if (!aurb) {

        free(data);

        return;

    }



    if (aurb->bulk_packet.endpoint != bulk_packet->endpoint ||

            aurb->bulk_packet.stream_id != bulk_packet->stream_id) {

        ERROR("return bulk packet mismatch, please report this!\n");

        len = USB_RET_NAK;

    }



    if (aurb->packet) {

        len = usbredir_handle_status(dev, bulk_packet->status, len);

        if (len > 0) {

            usbredir_log_data(dev, "bulk data in:", data, data_len);

            if (data_len <= aurb->packet->len) {

                memcpy(aurb->packet->data, data, data_len);

            } else {

                ERROR("bulk buffer too small (%d > %d)\n", data_len,

                      aurb->packet->len);

                len = USB_RET_STALL;

            }

        }

        aurb->packet->len = len;

        usb_packet_complete(&dev->dev, aurb->packet);

    }

    async_free(dev, aurb);

    free(data);

}

        aurb->packet->len = len;             if (data_len <= aurb->packet->len) {                 memcpy(aurb->packet->data, data, data_len);                 ERROR("bulk buffer too small (%d > %d)\n", data_len,                       aurb->packet->len);         aurb->packet->len = len;
static void FUNC_0(void *VAR_0, uint32_t VAR_1,

    struct usb_redir_bulk_packet_header *VAR_2,

    uint8_t *VAR_3, int VAR_4)

{

    USBRedirDevice *dev = VAR_0;

    uint8_t ep = VAR_2->endpoint;

    int VAR_5 = VAR_2->length;

    AsyncURB *aurb;



    DPRINTF("bulk-in status %d ep %02X VAR_5 %d VAR_1 %u\n", VAR_2->status,

            ep, VAR_5, VAR_1);



    aurb = async_find(dev, VAR_1);

    if (!aurb) {

        free(VAR_3);

        return;

    }



    if (aurb->VAR_2.endpoint != VAR_2->endpoint ||

            aurb->VAR_2.stream_id != VAR_2->stream_id) {

        ERROR("return bulk packet mismatch, please report this!\n");

        VAR_5 = USB_RET_NAK;

    }



    if (aurb->packet) {

        VAR_5 = usbredir_handle_status(dev, VAR_2->status, VAR_5);

        if (VAR_5 > 0) {

            usbredir_log_data(dev, "bulk VAR_3 in:", VAR_3, VAR_4);

            if (VAR_4 <= aurb->packet->VAR_5) {

                memcpy(aurb->packet->VAR_3, VAR_3, VAR_4);

            } else {

                ERROR("bulk buffer too small (%d > %d)\n", VAR_4,

                      aurb->packet->VAR_5);

                VAR_5 = USB_RET_STALL;

            }

        }

        aurb->packet->VAR_5 = VAR_5;

        usb_packet_complete(&dev->dev, aurb->packet);

    }

    async_free(dev, aurb);

    free(VAR_3);

}

static void FUNC_0(void *VAR_0, uint32_t VAR_1,
struct usb_redir_bulk_packet_header *VAR_2,
uint8_t *VAR_3, int VAR_4)
{ USBRedirDevice *dev = VAR_0; uint8_t ep = VAR_2->endpoint; int VAR_5 = VAR_2->length; AsyncURB *aurb; DPRINTF("bulk-in status %d ep %02X VAR_5 %d VAR_1 %u\n", VAR_2->status,
ep, VAR_5, VAR_1); aurb = async_find(dev, VAR_1); if (!aurb) { free(VAR_3); return; } if (aurb->VAR_2.endpoint != VAR_2->endpoint ||
aurb->VAR_2.stream_id != VAR_2->stream_id) { ERROR("return bulk packet mismatch, please report this!\n"); VAR_5 = USB_RET_NAK; } if (aurb->packet) { VAR_5 = usbredir_handle_status(dev, VAR_2->status, VAR_5); if (VAR_5 > 0) { usbredir_log_data(dev, "bulk VAR_3 in:", VAR_3, VAR_4); if (VAR_4 <= aurb->packet->VAR_5) { memcpy(aurb->packet->VAR_3, VAR_3, VAR_4); } else { ERROR("bulk buffer too small (%d > %d)\n", VAR_4,
aurb->packet->VAR_5); VAR_5 = USB_RET_STALL; } } aurb->packet->VAR_5 = VAR_5; usb_packet_complete(&dev->dev, aurb->packet); } async_free(dev, aurb); free(VAR_3); }