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>
30 #define DEVICE_HARDWARE_ID_SIZE 32
31 #define DEVICE_COMPATIBILITY_ID_SIZE 36
32 #define DEVICE_INSTANCE_STR_SIZE 37
33 #define DEVICE_CONTAINER_STR_SIZE 39
35 #define TAG CHANNELS_TAG("urbdrc.client")
37 #define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__)
39 #define DEBUG_DVC(...) \
48 #define BASIC_DEV_STATE_DEFINED(_arg, _type) \
49 _type (*get_##_arg)(IUDEVICE * pdev); \
50 void (*set_##_arg)(IUDEVICE * pdev, _type _arg)
52 #define BASIC_DEVMAN_STATE_DEFINED(_arg, _type) \
53 _type (*get_##_arg)(IUDEVMAN * udevman); \
54 void (*set_##_arg)(IUDEVMAN * udevman, _type _arg)
63 UINT32 vchannel_status;
67 IWTSListener* listener;
71 typedef BOOL (*PREGISTERURBDRCSERVICE)(IWTSPlugin* plugin, IUDEVMAN* udevman);
75 PREGISTERURBDRCSERVICE pRegisterUDEVMAN;
80 typedef UINT(VCAPITYPE* PFREERDP_URBDRC_DEVICE_ENTRY)(
88 IWTSVirtualChannel* channel;
93 wStream* out, UINT32 InterfaceId, BOOL noAck, UINT32 MessageId,
94 UINT32 RequestId, UINT32 NumberOfPackets, UINT32 status,
95 UINT32 StartFrame, UINT32 ErrorCount, UINT32 OutputBufferSize);
101 UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags,
102 UINT32 StartFrame, UINT32 ErrorCount, BOOL NoAck,
103 const BYTE* packetDescriptorData, UINT32 NumberOfPackets,
104 UINT32 BufferSize,
const BYTE* Buffer, t_isoch_transfer_cb cb,
107 BOOL(*control_transfer)
108 (IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags,
109 BYTE bmRequestType, BYTE Request, UINT16 Value, UINT16 Index, UINT32* UrbdStatus,
110 UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout);
113 UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress,
114 UINT32 TransferFlags, BOOL NoAck, UINT32 BufferSize,
115 const BYTE* data, t_isoch_transfer_cb cb, UINT32 Timeout);
117 int (*select_configuration)(IUDEVICE* idev, UINT32 bConfigurationValue);
119 int (*select_interface)(IUDEVICE* idev, BYTE InterfaceNumber, BYTE AlternateSetting);
121 int (*control_pipe_request)(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
122 UINT32* UsbdStatus,
int command);
124 UINT32(*control_query_device_text)
125 (IUDEVICE* idev, UINT32 TextType, UINT16 LocaleId, UINT8* BufferSize, BYTE* Buffer);
127 int (*os_feature_descriptor_request)(IUDEVICE* idev, UINT32 RequestId, BYTE Recipient,
128 BYTE InterfaceNumber, BYTE Ms_PageIndex,
129 UINT16 Ms_featureDescIndex, UINT32* UsbdStatus,
130 UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout);
132 void (*cancel_all_transfer_request)(IUDEVICE* idev);
134 int (*cancel_transfer_request)(IUDEVICE* idev, UINT32 RequestId);
136 int (*query_device_descriptor)(IUDEVICE* idev,
int offset);
138 BOOL (*detach_kernel_driver)(IUDEVICE* idev);
140 BOOL (*attach_kernel_driver)(IUDEVICE* idev);
142 int (*query_device_port_status)(IUDEVICE* idev, UINT32* UsbdStatus, UINT32* BufferSize,
148 int (*isCompositeDevice)(IUDEVICE* idev);
150 int (*isExist)(IUDEVICE* idev);
151 int (*isAlreadySend)(IUDEVICE* idev);
152 int (*isChannelClosed)(IUDEVICE* idev);
154 void (*setAlreadySend)(IUDEVICE* idev);
155 void (*setChannelClosed)(IUDEVICE* idev);
156 void (*markChannelClosed)(IUDEVICE* idev);
157 char* (*getPath)(IUDEVICE* idev);
159 void (*free)(IUDEVICE* idev);
161 BASIC_DEV_STATE_DEFINED(channelManager, IWTSVirtualChannelManager*);
162 BASIC_DEV_STATE_DEFINED(channelID, UINT32);
163 BASIC_DEV_STATE_DEFINED(UsbDevice, UINT32);
164 BASIC_DEV_STATE_DEFINED(ReqCompletion, UINT32);
165 BASIC_DEV_STATE_DEFINED(bus_number, BYTE);
166 BASIC_DEV_STATE_DEFINED(dev_number, BYTE);
167 BASIC_DEV_STATE_DEFINED(port_number, UINT8);
170 BASIC_DEV_STATE_DEFINED(p_udev,
void*);
171 BASIC_DEV_STATE_DEFINED(p_prev,
void*);
172 BASIC_DEV_STATE_DEFINED(p_next,
void*);
178 void (*free)(IUDEVMAN* idevman);
181 void (*rewind)(IUDEVMAN* idevman);
182 BOOL (*has_next)(IUDEVMAN* idevman);
183 BOOL (*unregister_udevice)(IUDEVMAN* idevman, BYTE bus_number, BYTE dev_number);
184 size_t (*register_udevice)(IUDEVMAN* idevman, BYTE bus_number, BYTE dev_number, UINT16 idVendor,
185 UINT16 idProduct, UINT32 flag);
186 IUDEVICE* (*get_next)(IUDEVMAN* idevman);
187 IUDEVICE* (*get_udevice_by_UsbDevice)(IUDEVMAN* idevman, UINT32 UsbDevice);
188 IUDEVICE* (*get_udevice_by_ChannelID)(IUDEVMAN* idevman, UINT32 channelID);
191 int (*isAutoAdd)(IUDEVMAN* idevman);
194 BASIC_DEVMAN_STATE_DEFINED(device_num, UINT32);
195 BASIC_DEVMAN_STATE_DEFINED(next_device_id, UINT32);
198 void (*loading_lock)(IUDEVMAN* idevman);
199 void (*loading_unlock)(IUDEVMAN* idevman);
200 BOOL (*initialize)(IUDEVMAN* idevman, UINT32 channelId);
201 UINT (*listener_created_callback)(IUDEVMAN* idevman);
204 UINT32 controlChannelId;
208 #define DEVICE_ADD_FLAG_BUS 0x01
209 #define DEVICE_ADD_FLAG_DEV 0x02
210 #define DEVICE_ADD_FLAG_VENDOR 0x04
211 #define DEVICE_ADD_FLAG_PRODUCT 0x08
212 #define DEVICE_ADD_FLAG_REGISTER 0x10
214 #define DEVICE_ADD_FLAG_ALL \
215 (DEVICE_ADD_FLAG_BUS | DEVICE_ADD_FLAG_DEV | DEVICE_ADD_FLAG_VENDOR | \
216 DEVICE_ADD_FLAG_PRODUCT | DEVICE_ADD_FLAG_REGISTER)
218 FREERDP_API BOOL add_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum,
219 UINT16 idVendor, UINT16 idProduct);
220 FREERDP_API BOOL del_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum,
221 UINT16 idVendor, UINT16 idProduct);
223 UINT stream_write_and_free(IWTSPlugin* plugin, IWTSVirtualChannel* channel,
wStream* out);