2012-04-25 22:26:35 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2012-04-25 22:26:35 +04:00
|
|
|
* RemoteFX USB Redirection
|
|
|
|
*
|
|
|
|
* Copyright 2012 Atrust corp.
|
|
|
|
* Copyright 2012 Alfred Liu <alfred.liu@atruscorp.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-06-06 15:01:41 +03:00
|
|
|
#ifndef FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H
|
|
|
|
#define FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
#include <winpr/pool.h>
|
|
|
|
#include <freerdp/channels/log.h>
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define DEVICE_HARDWARE_ID_SIZE 32
|
|
|
|
#define DEVICE_COMPATIBILITY_ID_SIZE 36
|
|
|
|
#define DEVICE_INSTANCE_STR_SIZE 37
|
|
|
|
#define DEVICE_CONTAINER_STR_SIZE 39
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
#define TAG CHANNELS_TAG("urbdrc.client")
|
|
|
|
#ifdef WITH_DEBUG_DVC
|
|
|
|
#define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define DEBUG_DVC(...) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
typedef struct _IUDEVICE IUDEVICE;
|
|
|
|
typedef struct _IUDEVMAN IUDEVMAN;
|
|
|
|
|
|
|
|
#define BASIC_DEV_STATE_DEFINED(_arg, _type) \
|
2019-11-06 17:24:51 +03:00
|
|
|
_type (*get_##_arg)(IUDEVICE * pdev); \
|
|
|
|
void (*set_##_arg)(IUDEVICE * pdev, _type _arg)
|
2012-11-21 04:34:52 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
#define BASIC_DEVMAN_STATE_DEFINED(_arg, _type) \
|
2019-11-06 17:24:51 +03:00
|
|
|
_type (*get_##_arg)(IUDEVMAN * udevman); \
|
|
|
|
void (*set_##_arg)(IUDEVMAN * udevman, _type _arg)
|
2012-04-25 22:26:35 +04:00
|
|
|
|
|
|
|
typedef struct _URBDRC_LISTENER_CALLBACK URBDRC_LISTENER_CALLBACK;
|
2012-10-03 00:54:14 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
struct _URBDRC_LISTENER_CALLBACK
|
|
|
|
{
|
|
|
|
IWTSListenerCallback iface;
|
|
|
|
|
2012-10-03 00:54:14 +04:00
|
|
|
IWTSPlugin* plugin;
|
|
|
|
IWTSVirtualChannelManager* channel_mgr;
|
2012-04-25 22:26:35 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _URBDRC_CHANNEL_CALLBACK URBDRC_CHANNEL_CALLBACK;
|
2012-10-03 00:54:14 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
struct _URBDRC_CHANNEL_CALLBACK
|
|
|
|
{
|
|
|
|
IWTSVirtualChannelCallback iface;
|
|
|
|
|
2012-10-03 00:54:14 +04:00
|
|
|
IWTSPlugin* plugin;
|
|
|
|
IWTSVirtualChannelManager* channel_mgr;
|
|
|
|
IWTSVirtualChannel* channel;
|
2012-04-25 22:26:35 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _URBDRC_PLUGIN URBDRC_PLUGIN;
|
2012-10-03 00:54:14 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
struct _URBDRC_PLUGIN
|
|
|
|
{
|
|
|
|
IWTSPlugin iface;
|
|
|
|
|
2012-10-03 00:54:14 +04:00
|
|
|
URBDRC_LISTENER_CALLBACK* listener_callback;
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2012-10-03 00:54:14 +04:00
|
|
|
IUDEVMAN* udevman;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 vchannel_status;
|
2012-11-21 04:34:52 +04:00
|
|
|
char* subsystem;
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
wLog* log;
|
2020-05-12 15:26:45 +03:00
|
|
|
IWTSListener* listener;
|
2019-11-22 12:42:05 +03:00
|
|
|
};
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
typedef BOOL (*PREGISTERURBDRCSERVICE)(IWTSPlugin* plugin, IUDEVMAN* udevman);
|
2012-04-25 22:26:35 +04:00
|
|
|
struct _FREERDP_URBDRC_SERVICE_ENTRY_POINTS
|
|
|
|
{
|
|
|
|
IWTSPlugin* plugin;
|
|
|
|
PREGISTERURBDRCSERVICE pRegisterUDEVMAN;
|
2012-11-21 04:34:52 +04:00
|
|
|
ADDIN_ARGV* args;
|
2012-04-25 22:26:35 +04:00
|
|
|
};
|
|
|
|
typedef struct _FREERDP_URBDRC_SERVICE_ENTRY_POINTS FREERDP_URBDRC_SERVICE_ENTRY_POINTS;
|
|
|
|
typedef FREERDP_URBDRC_SERVICE_ENTRY_POINTS* PFREERDP_URBDRC_SERVICE_ENTRY_POINTS;
|
|
|
|
|
|
|
|
typedef int (*PFREERDP_URBDRC_DEVICE_ENTRY)(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS pEntryPoints);
|
|
|
|
|
|
|
|
typedef struct _TRANSFER_DATA TRANSFER_DATA;
|
2012-10-03 00:54:14 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
struct _TRANSFER_DATA
|
|
|
|
{
|
2012-10-03 00:54:14 +04:00
|
|
|
URBDRC_CHANNEL_CALLBACK* callback;
|
|
|
|
URBDRC_PLUGIN* urbdrc;
|
|
|
|
IUDEVMAN* udevman;
|
2019-11-22 12:42:05 +03:00
|
|
|
IWTSVirtualChannel* channel;
|
|
|
|
wStream* s;
|
2012-04-25 22:26:35 +04:00
|
|
|
};
|
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
typedef void (*t_isoch_transfer_cb)(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* callback, wStream* out,
|
|
|
|
UINT32 InterfaceId, BOOL noAck, UINT32 MessageId,
|
|
|
|
UINT32 RequestId, UINT32 NumberOfPackets, UINT32 status,
|
|
|
|
UINT32 StartFrame, UINT32 ErrorCount, UINT32 OutputBufferSize);
|
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
struct _IUDEVICE
|
|
|
|
{
|
|
|
|
/* Transfer */
|
2019-11-22 12:42:05 +03:00
|
|
|
int (*isoch_transfer)(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* callback, UINT32 MessageId,
|
|
|
|
UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags,
|
|
|
|
UINT32 StartFrame, UINT32 ErrorCount, BOOL NoAck,
|
|
|
|
const BYTE* packetDescriptorData, UINT32 NumberOfPackets,
|
|
|
|
UINT32 BufferSize, const BYTE* Buffer, t_isoch_transfer_cb cb,
|
|
|
|
UINT32 Timeout);
|
|
|
|
|
|
|
|
BOOL(*control_transfer)
|
|
|
|
(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags,
|
|
|
|
BYTE bmRequestType, BYTE Request, UINT16 Value, UINT16 Index, UINT32* UrbdStatus,
|
|
|
|
UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout);
|
|
|
|
|
|
|
|
int (*bulk_or_interrupt_transfer)(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* callback,
|
|
|
|
UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress,
|
|
|
|
UINT32 TransferFlags, BOOL NoAck, UINT32 BufferSize,
|
|
|
|
t_isoch_transfer_cb cb, UINT32 Timeout);
|
2012-11-21 04:34:52 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*select_configuration)(IUDEVICE* idev, UINT32 bConfigurationValue);
|
2012-11-21 04:34:52 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*select_interface)(IUDEVICE* idev, BYTE InterfaceNumber, BYTE AlternateSetting);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*control_pipe_request)(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
|
|
|
|
UINT32* UsbdStatus, int command);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
UINT32(*control_query_device_text)
|
|
|
|
(IUDEVICE* idev, UINT32 TextType, UINT16 LocaleId, UINT8* BufferSize, BYTE* Buffer);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*os_feature_descriptor_request)(IUDEVICE* idev, UINT32 RequestId, BYTE Recipient,
|
|
|
|
BYTE InterfaceNumber, BYTE Ms_PageIndex,
|
|
|
|
UINT16 Ms_featureDescIndex, UINT32* UsbdStatus,
|
|
|
|
UINT32* BufferSize, BYTE* Buffer, int Timeout);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
void (*cancel_all_transfer_request)(IUDEVICE* idev);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*cancel_transfer_request)(IUDEVICE* idev, UINT32 RequestId);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*query_device_descriptor)(IUDEVICE* idev, int offset);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
BOOL (*detach_kernel_driver)(IUDEVICE* idev);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
BOOL (*attach_kernel_driver)(IUDEVICE* idev);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*query_device_port_status)(IUDEVICE* idev, UINT32* UsbdStatus, UINT32* BufferSize,
|
|
|
|
BYTE* Buffer);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
MSUSB_CONFIG_DESCRIPTOR* (*complete_msconfig_setup)(IUDEVICE* idev,
|
|
|
|
MSUSB_CONFIG_DESCRIPTOR* MsConfig);
|
2012-04-25 22:26:35 +04:00
|
|
|
/* Basic state */
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*isCompositeDevice)(IUDEVICE* idev);
|
2019-11-22 12:42:05 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*isExist)(IUDEVICE* idev);
|
|
|
|
int (*isAlreadySend)(IUDEVICE* idev);
|
|
|
|
int (*isChannelClosed)(IUDEVICE* idev);
|
2019-11-22 12:42:05 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
void (*setAlreadySend)(IUDEVICE* idev);
|
|
|
|
void (*setChannelClosed)(IUDEVICE* idev);
|
|
|
|
char* (*getPath)(IUDEVICE* idev);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2019-11-22 12:42:05 +03:00
|
|
|
void (*free)(IUDEVICE* idev);
|
|
|
|
|
|
|
|
BASIC_DEV_STATE_DEFINED(channelManager, IWTSVirtualChannelManager*);
|
|
|
|
BASIC_DEV_STATE_DEFINED(channelID, UINT32);
|
2012-10-09 11:26:39 +04:00
|
|
|
BASIC_DEV_STATE_DEFINED(UsbDevice, UINT32);
|
|
|
|
BASIC_DEV_STATE_DEFINED(ReqCompletion, UINT32);
|
2019-11-22 12:42:05 +03:00
|
|
|
BASIC_DEV_STATE_DEFINED(bus_number, BYTE);
|
|
|
|
BASIC_DEV_STATE_DEFINED(dev_number, BYTE);
|
2012-04-25 22:26:35 +04:00
|
|
|
BASIC_DEV_STATE_DEFINED(port_number, int);
|
2012-11-21 04:34:52 +04:00
|
|
|
BASIC_DEV_STATE_DEFINED(MsConfig, MSUSB_CONFIG_DESCRIPTOR*);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2012-11-21 04:34:52 +04:00
|
|
|
BASIC_DEV_STATE_DEFINED(p_udev, void*);
|
|
|
|
BASIC_DEV_STATE_DEFINED(p_prev, void*);
|
|
|
|
BASIC_DEV_STATE_DEFINED(p_next, void*);
|
2012-04-25 22:26:35 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _IUDEVMAN
|
|
|
|
{
|
|
|
|
/* Standard */
|
2019-11-06 17:24:51 +03:00
|
|
|
void (*free)(IUDEVMAN* idevman);
|
2012-11-21 04:34:52 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
/* Manage devices */
|
2019-11-06 17:24:51 +03:00
|
|
|
void (*rewind)(IUDEVMAN* idevman);
|
2019-11-22 12:42:05 +03:00
|
|
|
BOOL (*has_next)(IUDEVMAN* idevman);
|
|
|
|
BOOL (*unregister_udevice)(IUDEVMAN* idevman, BYTE bus_number, BYTE dev_number);
|
2020-02-28 15:45:26 +03:00
|
|
|
size_t (*register_udevice)(IUDEVMAN* idevman, BYTE bus_number, BYTE dev_number, UINT16 idVendor,
|
|
|
|
UINT16 idProduct, UINT32 flag);
|
2019-11-06 17:24:51 +03:00
|
|
|
IUDEVICE* (*get_next)(IUDEVMAN* idevman);
|
|
|
|
IUDEVICE* (*get_udevice_by_UsbDevice)(IUDEVMAN* idevman, UINT32 UsbDevice);
|
2012-11-21 04:34:52 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
/* Extension */
|
2019-11-06 17:24:51 +03:00
|
|
|
int (*isAutoAdd)(IUDEVMAN* idevman);
|
2012-11-21 04:34:52 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
/* Basic state */
|
2019-11-22 12:42:05 +03:00
|
|
|
BASIC_DEVMAN_STATE_DEFINED(device_num, UINT32);
|
2020-02-28 15:45:26 +03:00
|
|
|
BASIC_DEVMAN_STATE_DEFINED(next_device_id, UINT32);
|
2012-11-21 04:34:52 +04:00
|
|
|
|
2012-04-25 22:26:35 +04:00
|
|
|
/* control semaphore or mutex lock */
|
2019-11-06 17:24:51 +03:00
|
|
|
void (*loading_lock)(IUDEVMAN* idevman);
|
|
|
|
void (*loading_unlock)(IUDEVMAN* idevman);
|
2019-11-22 12:42:05 +03:00
|
|
|
BOOL (*initialize)(IUDEVMAN* idevman, UINT32 channelId);
|
2020-04-23 06:13:13 +03:00
|
|
|
UINT (*listener_created_callback)(IUDEVMAN* idevman);
|
2019-11-22 12:42:05 +03:00
|
|
|
|
|
|
|
IWTSPlugin* plugin;
|
|
|
|
UINT32 controlChannelId;
|
2020-03-03 13:09:27 +03:00
|
|
|
UINT32 status;
|
2012-04-25 22:26:35 +04:00
|
|
|
};
|
2020-02-11 14:41:07 +03:00
|
|
|
|
2020-04-10 15:16:19 +03:00
|
|
|
#define DEVICE_ADD_FLAG_BUS 0x01
|
|
|
|
#define DEVICE_ADD_FLAG_DEV 0x02
|
|
|
|
#define DEVICE_ADD_FLAG_VENDOR 0x04
|
|
|
|
#define DEVICE_ADD_FLAG_PRODUCT 0x08
|
|
|
|
#define DEVICE_ADD_FLAG_REGISTER 0x10
|
|
|
|
|
2020-02-28 15:45:26 +03:00
|
|
|
#define DEVICE_ADD_FLAG_ALL \
|
|
|
|
(DEVICE_ADD_FLAG_BUS | DEVICE_ADD_FLAG_DEV | DEVICE_ADD_FLAG_VENDOR | \
|
|
|
|
DEVICE_ADD_FLAG_PRODUCT | DEVICE_ADD_FLAG_REGISTER)
|
|
|
|
|
|
|
|
FREERDP_API BOOL add_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum,
|
|
|
|
UINT16 idVendor, UINT16 idProduct);
|
2020-03-02 10:40:40 +03:00
|
|
|
FREERDP_API BOOL del_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum,
|
|
|
|
UINT16 idVendor, UINT16 idProduct);
|
2019-11-22 12:42:05 +03:00
|
|
|
|
|
|
|
UINT stream_write_and_free(IWTSPlugin* plugin, IWTSVirtualChannel* channel, wStream* s);
|
2012-04-25 22:26:35 +04:00
|
|
|
|
2017-06-06 15:01:41 +03:00
|
|
|
#endif /* FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H */
|