dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info)
{
    proto_item *item;
    proto_tree *tree;
    int old_offset=offset;
    struct usb_hid_global_state initial_global;

    memset(&initial_global, 0, sizeof(struct usb_hid_global_state));

    item = proto_tree_add_protocol_format(parent_tree, proto_usb_hid, tvb, offset,
                                          -1, "HID Report");
    tree = proto_item_add_subtree(item, ett_usb_hid_report);
    offset = dissect_usb_hid_report_item(pinfo, tree, tvb, offset, usb_conv_info, &initial_global);

    /* only insert report descriptor the first time we parse it */
    if (!PINFO_FD_VISITED(pinfo) && usb_conv_info) {
        wmem_allocator_t *scope = wmem_file_scope();
        report_descriptor_t *data = wmem_new(scope, report_descriptor_t);

        data->usb_info = *usb_conv_info;
        data->desc_length = offset - old_offset;
        data->desc_body = (guint8*) tvb_memdup(scope, tvb, old_offset, data->desc_length);

        if (parse_report_descriptor(data)) {
            insert_report_descriptor(pinfo, data);
        } else {
            wmem_free(scope, data->desc_body);
            wmem_free(scope, data);
        }
    }

    proto_item_set_len(item, offset-old_offset);

    return offset;
}
dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info)
{
    proto_item *item;
    proto_tree *tree;
    int old_offset=offset;
    struct usb_hid_global_state initial_global;

    memset(&initial_global, 0, sizeof(struct usb_hid_global_state));

    item = proto_tree_add_protocol_format(parent_tree, proto_usb_hid, tvb, offset,
                                          -1, "HID Report");
    tree = proto_item_add_subtree(item, ett_usb_hid_report);
    offset = dissect_usb_hid_report_item(pinfo, tree, tvb, offset, usb_conv_info, &initial_global);

     
    if (!PINFO_FD_VISITED(pinfo) && usb_conv_info) {
        wmem_allocator_t *scope = wmem_file_scope();
        report_descriptor_t *data = wmem_new(scope, report_descriptor_t);

        data->usb_info = *usb_conv_info;
        data->desc_length = offset - old_offset;
        data->desc_body = (guint8*) tvb_memdup(scope, tvb, old_offset, data->desc_length);

        if (parse_report_descriptor(data)) {
            insert_report_descriptor(pinfo, data);
        } else {
            wmem_free(scope, data->desc_body);
            wmem_free(scope, data);
        }
    }

    proto_item_set_len(item, offset-old_offset);

    return offset;
}