21 #ifndef FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H
22 #define FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H
24 #include <winpr/pool.h>
25 #include <freerdp/channels/log.h>
26 #include <freerdp/client/channels.h>
28 #define DEVICE_HARDWARE_ID_SIZE 32
29 #define DEVICE_COMPATIBILITY_ID_SIZE 36
30 #define DEVICE_INSTANCE_STR_SIZE 37
31 #define DEVICE_CONTAINER_STR_SIZE 39
33 #define TAG CHANNELS_TAG("urbdrc.client")
35 #define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__)
37 #define DEBUG_DVC(...) \
46 #define BASIC_DEV_STATE_DEFINED(_arg, _type) \
47 _type (*get_##_arg)(IUDEVICE * pdev); \
48 void (*set_##_arg)(IUDEVICE * pdev, _type _arg)
50 #define BASIC_DEVMAN_STATE_DEFINED(_arg, _type) \
51 _type (*get_##_arg)(IUDEVMAN * udevman); \
52 void (*set_##_arg)(IUDEVMAN * udevman, _type _arg)
61 UINT32 vchannel_status;
65 IWTSListener* listener;
69 typedef BOOL (*PREGISTERURBDRCSERVICE)(IWTSPlugin* plugin, IUDEVMAN* udevman);
73 PREGISTERURBDRCSERVICE pRegisterUDEVMAN;
78 typedef UINT(VCAPITYPE* PFREERDP_URBDRC_DEVICE_ENTRY)(
86 IWTSVirtualChannel* channel;
91 wStream* out, UINT32 InterfaceId, BOOL noAck, UINT32 MessageId,
92 UINT32 RequestId, UINT32 NumberOfPackets, UINT32 status,
93 UINT32 StartFrame, UINT32 ErrorCount, UINT32 OutputBufferSize);
99 UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags,
100 UINT32 StartFrame, UINT32 ErrorCount, BOOL NoAck,
101 const BYTE* packetDescriptorData, UINT32 NumberOfPackets,
102 UINT32 BufferSize,
const BYTE* Buffer, t_isoch_transfer_cb cb,
105 BOOL(*control_transfer)
106 (IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags,
107 BYTE bmRequestType, BYTE Request, UINT16 Value, UINT16 Index, UINT32* UrbdStatus,
108 UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout);
111 UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress,
112 UINT32 TransferFlags, BOOL NoAck, UINT32 BufferSize,
113 const BYTE* data, t_isoch_transfer_cb cb, UINT32 Timeout);
115 int (*select_configuration)(IUDEVICE* idev, UINT32 bConfigurationValue);
117 int (*select_interface)(IUDEVICE* idev, BYTE InterfaceNumber, BYTE AlternateSetting);
119 int (*control_pipe_request)(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
120 UINT32* UsbdStatus,
int command);
122 UINT32(*control_query_device_text)
123 (IUDEVICE* idev, UINT32 TextType, UINT16 LocaleId, UINT8* BufferSize, BYTE* Buffer);
125 int (*os_feature_descriptor_request)(IUDEVICE* idev, UINT32 RequestId, BYTE Recipient,
126 BYTE InterfaceNumber, BYTE Ms_PageIndex,
127 UINT16 Ms_featureDescIndex, UINT32* UsbdStatus,
128 UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout);
130 void (*cancel_all_transfer_request)(IUDEVICE* idev);
132 int (*cancel_transfer_request)(IUDEVICE* idev, UINT32 RequestId);
134 int (*query_device_descriptor)(IUDEVICE* idev,
int offset);
136 BOOL (*detach_kernel_driver)(IUDEVICE* idev);
138 BOOL (*attach_kernel_driver)(IUDEVICE* idev);
140 int (*query_device_port_status)(IUDEVICE* idev, UINT32* UsbdStatus, UINT32* BufferSize,
146 int (*isCompositeDevice)(IUDEVICE* idev);
148 int (*isExist)(IUDEVICE* idev);
149 int (*isAlreadySend)(IUDEVICE* idev);
150 int (*isChannelClosed)(IUDEVICE* idev);
152 void (*setAlreadySend)(IUDEVICE* idev);
153 void (*setChannelClosed)(IUDEVICE* idev);
154 void (*markChannelClosed)(IUDEVICE* idev);
155 char* (*getPath)(IUDEVICE* idev);
157 void (*free)(IUDEVICE* idev);
159 BASIC_DEV_STATE_DEFINED(channelManager, IWTSVirtualChannelManager*);
160 BASIC_DEV_STATE_DEFINED(channelID, UINT32);
161 BASIC_DEV_STATE_DEFINED(UsbDevice, UINT32);
162 BASIC_DEV_STATE_DEFINED(ReqCompletion, UINT32);
163 BASIC_DEV_STATE_DEFINED(bus_number, BYTE);
164 BASIC_DEV_STATE_DEFINED(dev_number, BYTE);
165 BASIC_DEV_STATE_DEFINED(port_number,
int);
168 BASIC_DEV_STATE_DEFINED(p_udev,
void*);
169 BASIC_DEV_STATE_DEFINED(p_prev,
void*);
170 BASIC_DEV_STATE_DEFINED(p_next,
void*);
176 void (*free)(IUDEVMAN* idevman);
179 void (*rewind)(IUDEVMAN* idevman);
180 BOOL (*has_next)(IUDEVMAN* idevman);
181 BOOL (*unregister_udevice)(IUDEVMAN* idevman, BYTE bus_number, BYTE dev_number);
182 size_t (*register_udevice)(IUDEVMAN* idevman, BYTE bus_number, BYTE dev_number, UINT16 idVendor,
183 UINT16 idProduct, UINT32 flag);
184 IUDEVICE* (*get_next)(IUDEVMAN* idevman);
185 IUDEVICE* (*get_udevice_by_UsbDevice)(IUDEVMAN* idevman, UINT32 UsbDevice);
186 IUDEVICE* (*get_udevice_by_ChannelID)(IUDEVMAN* idevman, UINT32 channelID);
189 int (*isAutoAdd)(IUDEVMAN* idevman);
192 BASIC_DEVMAN_STATE_DEFINED(device_num, UINT32);
193 BASIC_DEVMAN_STATE_DEFINED(next_device_id, UINT32);
196 void (*loading_lock)(IUDEVMAN* idevman);
197 void (*loading_unlock)(IUDEVMAN* idevman);
198 BOOL (*initialize)(IUDEVMAN* idevman, UINT32 channelId);
199 UINT (*listener_created_callback)(IUDEVMAN* idevman);
202 UINT32 controlChannelId;
206 #define DEVICE_ADD_FLAG_BUS 0x01
207 #define DEVICE_ADD_FLAG_DEV 0x02
208 #define DEVICE_ADD_FLAG_VENDOR 0x04
209 #define DEVICE_ADD_FLAG_PRODUCT 0x08
210 #define DEVICE_ADD_FLAG_REGISTER 0x10
212 #define DEVICE_ADD_FLAG_ALL \
213 (DEVICE_ADD_FLAG_BUS | DEVICE_ADD_FLAG_DEV | DEVICE_ADD_FLAG_VENDOR | \
214 DEVICE_ADD_FLAG_PRODUCT | DEVICE_ADD_FLAG_REGISTER)
216 FREERDP_API BOOL add_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum,
217 UINT16 idVendor, UINT16 idProduct);
218 FREERDP_API BOOL del_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum,
219 UINT16 idVendor, UINT16 idProduct);
221 UINT stream_write_and_free(IWTSPlugin* plugin, IWTSVirtualChannel* channel,
wStream* out);