static int usbredir_handle_control(USBDevice *udev, USBPacket *p,

        int request, int value, int index, int length, uint8_t *data)

{

    USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev);

    struct usb_redir_control_packet_header control_packet;

    AsyncURB *aurb;



    /* Special cases for certain standard device requests */

    switch (request) {

    case DeviceOutRequest | USB_REQ_SET_ADDRESS:

        DPRINTF("set address %d\n", value);

        dev->dev.addr = value;

        return 0;

    case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:

        return usbredir_set_config(dev, p, value & 0xff);

    case DeviceRequest | USB_REQ_GET_CONFIGURATION:

        return usbredir_get_config(dev, p);

    case InterfaceOutRequest | USB_REQ_SET_INTERFACE:

        return usbredir_set_interface(dev, p, index, value);

    case InterfaceRequest | USB_REQ_GET_INTERFACE:

        return usbredir_get_interface(dev, p, index);

    }



    /* "Normal" ctrl requests */

    aurb = async_alloc(dev, p);



    /* Note request is (bRequestType << 8) | bRequest */

    DPRINTF("ctrl-out type 0x%x req 0x%x val 0x%x index %d len %d id %u\n",

            request >> 8, request & 0xff, value, index, length,

            aurb->packet_id);



    control_packet.request     = request & 0xFF;

    control_packet.requesttype = request >> 8;

    control_packet.endpoint    = control_packet.requesttype & USB_DIR_IN;

    control_packet.value       = value;

    control_packet.index       = index;

    control_packet.length      = length;

    aurb->control_packet       = control_packet;



    if (control_packet.requesttype & USB_DIR_IN) {

        usbredirparser_send_control_packet(dev->parser, aurb->packet_id,

                                           &control_packet, NULL, 0);

    } else {

        usbredir_log_data(dev, "ctrl data out:", data, length);

        usbredirparser_send_control_packet(dev->parser, aurb->packet_id,

                                           &control_packet, data, length);

    }

    usbredirparser_do_write(dev->parser);

    return USB_RET_ASYNC;

}

static int usbredir_handle_control(USBDevice *udev, USBPacket *p,

        int request, int value, int index, int length, uint8_t *data)

{

    USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev);

    struct usb_redir_control_packet_header control_packet;

    AsyncURB *aurb;



    

    switch (request) {

    case DeviceOutRequest | USB_REQ_SET_ADDRESS:

        DPRINTF("set address %d\n", value);

        dev->dev.addr = value;

        return 0;

    case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:

        return usbredir_set_config(dev, p, value & 0xff);

    case DeviceRequest | USB_REQ_GET_CONFIGURATION:

        return usbredir_get_config(dev, p);

    case InterfaceOutRequest | USB_REQ_SET_INTERFACE:

        return usbredir_set_interface(dev, p, index, value);

    case InterfaceRequest | USB_REQ_GET_INTERFACE:

        return usbredir_get_interface(dev, p, index);

    }



    

    aurb = async_alloc(dev, p);



    

    DPRINTF("ctrl-out type 0x%x req 0x%x val 0x%x index %d len %d id %u\n",

            request >> 8, request & 0xff, value, index, length,

            aurb->packet_id);



    control_packet.request     = request & 0xFF;

    control_packet.requesttype = request >> 8;

    control_packet.endpoint    = control_packet.requesttype & USB_DIR_IN;

    control_packet.value       = value;

    control_packet.index       = index;

    control_packet.length      = length;

    aurb->control_packet       = control_packet;



    if (control_packet.requesttype & USB_DIR_IN) {

        usbredirparser_send_control_packet(dev->parser, aurb->packet_id,

                                           &control_packet, NULL, 0);

    } else {

        usbredir_log_data(dev, "ctrl data out:", data, length);

        usbredirparser_send_control_packet(dev->parser, aurb->packet_id,

                                           &control_packet, data, length);

    }

    usbredirparser_do_write(dev->parser);

    return USB_RET_ASYNC;

}

static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1,

        int VAR_2, int VAR_3, int VAR_4, int VAR_5, uint8_t *VAR_6)

{

    USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, VAR_0);

    struct usb_redir_control_packet_header VAR_7;

    AsyncURB *aurb;



    

    switch (VAR_2) {

    case DeviceOutRequest | USB_REQ_SET_ADDRESS:

        DPRINTF("set address %d\n", VAR_3);

        dev->dev.addr = VAR_3;

        return 0;

    case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:

        return usbredir_set_config(dev, VAR_1, VAR_3 & 0xff);

    case DeviceRequest | USB_REQ_GET_CONFIGURATION:

        return usbredir_get_config(dev, VAR_1);

    case InterfaceOutRequest | USB_REQ_SET_INTERFACE:

        return usbredir_set_interface(dev, VAR_1, VAR_4, VAR_3);

    case InterfaceRequest | USB_REQ_GET_INTERFACE:

        return usbredir_get_interface(dev, VAR_1, VAR_4);

    }



    

    aurb = async_alloc(dev, VAR_1);



    

    DPRINTF("ctrl-out type 0x%x req 0x%x val 0x%x VAR_4 %d len %d id %u\n",

            VAR_2 >> 8, VAR_2 & 0xff, VAR_3, VAR_4, VAR_5,

            aurb->packet_id);



    VAR_7.VAR_2     = VAR_2 & 0xFF;

    VAR_7.requesttype = VAR_2 >> 8;

    VAR_7.endpoint    = VAR_7.requesttype & USB_DIR_IN;

    VAR_7.VAR_3       = VAR_3;

    VAR_7.VAR_4       = VAR_4;

    VAR_7.VAR_5      = VAR_5;

    aurb->VAR_7       = VAR_7;



    if (VAR_7.requesttype & USB_DIR_IN) {

        usbredirparser_send_control_packet(dev->parser, aurb->packet_id,

                                           &VAR_7, NULL, 0);

    } else {

        usbredir_log_data(dev, "ctrl VAR_6 out:", VAR_6, VAR_5);

        usbredirparser_send_control_packet(dev->parser, aurb->packet_id,

                                           &VAR_7, VAR_6, VAR_5);

    }

    usbredirparser_do_write(dev->parser);

    return USB_RET_ASYNC;

}

static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1,
int VAR_2, int VAR_3, int VAR_4, int VAR_5, uint8_t *VAR_6)
{ USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, VAR_0); struct usb_redir_control_packet_header VAR_7; AsyncURB *aurb; switch (VAR_2) { case DeviceOutRequest | USB_REQ_SET_ADDRESS:
DPRINTF("set address %d\n", VAR_3); dev->dev.addr = VAR_3; return 0; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
return usbredir_set_config(dev, VAR_1, VAR_3 & 0xff); case DeviceRequest | USB_REQ_GET_CONFIGURATION:
return usbredir_get_config(dev, VAR_1); case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
return usbredir_set_interface(dev, VAR_1, VAR_4, VAR_3); case InterfaceRequest | USB_REQ_GET_INTERFACE:
return usbredir_get_interface(dev, VAR_1, VAR_4); } aurb = async_alloc(dev, VAR_1); DPRINTF("ctrl-out type 0x%x req 0x%x val 0x%x VAR_4 %d len %d id %u\n",
VAR_2 >> 8, VAR_2 & 0xff, VAR_3, VAR_4, VAR_5,
aurb->packet_id); VAR_7.VAR_2     = VAR_2 & 0xFF; VAR_7.requesttype = VAR_2 >> 8; VAR_7.endpoint    = VAR_7.requesttype & USB_DIR_IN; VAR_7.VAR_3       = VAR_3; VAR_7.VAR_4       = VAR_4; VAR_7.VAR_5      = VAR_5; aurb->VAR_7       = VAR_7; if (VAR_7.requesttype & USB_DIR_IN) { usbredirparser_send_control_packet(dev->parser, aurb->packet_id,
&VAR_7, NULL, 0); } else { usbredir_log_data(dev, "ctrl VAR_6 out:", VAR_6, VAR_5); usbredirparser_send_control_packet(dev->parser, aurb->packet_id,
&VAR_7, VAR_6, VAR_5); } usbredirparser_do_write(dev->parser); return USB_RET_ASYNC; }