1 | /** @file
|
---|
2 | * VBox Remote Desktop Protocol:
|
---|
3 | * Public APIs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef __VBox_vrdpapi_h__
|
---|
23 | #define __VBox_vrdpapi_h__
|
---|
24 |
|
---|
25 | #include <VBox/cdefs.h>
|
---|
26 | #include <VBox/types.h>
|
---|
27 |
|
---|
28 | #ifdef IN_RING0
|
---|
29 | # error "There are no VRDP APIs available in Ring-0 Host Context!"
|
---|
30 | #endif
|
---|
31 | #ifdef IN_GC
|
---|
32 | # error "There are no VRDP APIs available Guest Context!"
|
---|
33 | #endif
|
---|
34 |
|
---|
35 |
|
---|
36 | /** @defgroup grp_vrdp VRDP
|
---|
37 | * VirtualBox Remote Desktop Protocol (VRDP) interface that allows to use
|
---|
38 | * the VRDP server.
|
---|
39 | * @{
|
---|
40 | */
|
---|
41 |
|
---|
42 | /** Flags for VDRPSetFramebuffer */
|
---|
43 | #define VRDP_INTERNAL_FRAMEBUFFER (0)
|
---|
44 | #define VRDP_EXTERNAL_FRAMEBUFFER (1)
|
---|
45 |
|
---|
46 | /** Default port that VRDP binds to */
|
---|
47 | #define VRDP_DEFAULT_PORT (3389)
|
---|
48 |
|
---|
49 | __BEGIN_DECLS
|
---|
50 |
|
---|
51 | /* Forward declaration */
|
---|
52 |
|
---|
53 | #ifdef __cplusplus
|
---|
54 |
|
---|
55 | class VRDPServer;
|
---|
56 | typedef class VRDPServer *HVRDPSERVER;
|
---|
57 |
|
---|
58 | #else
|
---|
59 |
|
---|
60 | struct VRDPServer;
|
---|
61 | typedef struct VRDPServer *HVRDPSERVER;
|
---|
62 |
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Start server for the specified IConsole.
|
---|
67 | *
|
---|
68 | * @return VBox status code
|
---|
69 | * @param pconsole Pointer to IConsole instance to fetch display, mouse and keyboard interfaces.
|
---|
70 | * @param pvrdpserver Pointer to IVRDPServer instance to fetch configuration.
|
---|
71 | * @param phserver Pointer to server instance handle,
|
---|
72 | * created by the function.
|
---|
73 | */
|
---|
74 | VRDPR3DECL(int) VRDPStartServer (IConsole *pconsole, IVRDPServer *pvrdpserver, HVRDPSERVER *phserver);
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Set framebuffer which will be delivered to client.
|
---|
79 | *
|
---|
80 | * @param hserver Handle of VRDP server instance.
|
---|
81 | * @param pframebuffer Pointer to external IFramebuffer to be used.
|
---|
82 | * @param flags VRDP_EXTERNAL_FRAMEBUFFER - the server must use supplied
|
---|
83 | * framebuffer or do not use framebuffer if pframebuffer == NULL
|
---|
84 | * VRDP_INTERNAL_FRAMEBUFFER - the server must create internal
|
---|
85 | * framebuffer and register it with Machine's IDisplay,
|
---|
86 | * pframebuffer ignored.
|
---|
87 | */
|
---|
88 | VRDPR3DECL(int) VRDPSetFramebuffer (HVRDPSERVER hserver, IFramebuffer *pframebuffer, uint32_t flags);
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Shutdown server.
|
---|
92 | *
|
---|
93 | * @param hserver Handle of VRDP server instance to be stopped.
|
---|
94 | */
|
---|
95 | VRDPR3DECL(void) VRDPShutdownServer (HVRDPSERVER hserver);
|
---|
96 |
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Send framebuffer bitmap to client.
|
---|
100 | *
|
---|
101 | * @param hserver Handle of VRDP server instance.
|
---|
102 | * @param x top left horizontal coordinate in framebuffer.
|
---|
103 | * @param y top left vertical coordinate in framebuffer.
|
---|
104 | * @param w width of rectangle.
|
---|
105 | * @param h height of rectangle.
|
---|
106 | */
|
---|
107 | VRDPR3DECL(void) VRDPSendUpdateBitmap (HVRDPSERVER hserver, unsigned x, unsigned y, unsigned w, unsigned h);
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * Inform client that display was resized.
|
---|
111 | * New width and height are taken from the current framebuffer.
|
---|
112 | *
|
---|
113 | * @param hserver Handle of VRDP server instance.
|
---|
114 | */
|
---|
115 | VRDPR3DECL(void) VRDPSendResize (HVRDPSERVER hserver);
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * Send an update in accelerated mode.
|
---|
119 | *
|
---|
120 | * @param hserver Handle of VRDP server instance.
|
---|
121 | * @param pvUpdate The update information. Actually pointer to VBoxGuest.h::VBVACMDHDR structure with extra data.
|
---|
122 | * @param cbUpdate Size of the update data.
|
---|
123 | */
|
---|
124 | VRDPR3DECL(void) VRDPSendUpdate (HVRDPSERVER hserver, void *pvUpdate, uint32_t cbUpdate);
|
---|
125 |
|
---|
126 | /** @todo comment the structure. */
|
---|
127 | typedef struct _VRDPCOLORPOINTER
|
---|
128 | {
|
---|
129 | uint16_t xHot;
|
---|
130 | uint16_t yHot;
|
---|
131 | uint16_t width;
|
---|
132 | uint16_t height;
|
---|
133 | uint16_t masklen;
|
---|
134 | uint16_t datalen;
|
---|
135 | uint32_t vrdpInternal;
|
---|
136 | } VRDPCOLORPOINTER;
|
---|
137 |
|
---|
138 | typedef VRDPCOLORPOINTER *PVRDPCOLORPOINTER;
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Set mouse pointer shape.
|
---|
142 | *
|
---|
143 | * @param hserver Handle of VRDP server instance.
|
---|
144 | * @param porder The pointer shape information.
|
---|
145 | */
|
---|
146 | VRDPR3DECL(void) VRDPSendColorPointer (HVRDPSERVER hserver, PVRDPCOLORPOINTER pdata);
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * Hide mouse pointer.
|
---|
150 | *
|
---|
151 | * @param hserver Handle of VRDP server instance.
|
---|
152 | */
|
---|
153 | VRDPR3DECL(void) VRDPSendHidePointer (HVRDPSERVER hserver);
|
---|
154 |
|
---|
155 | /** Audio format information packed in a 32 bit value. */
|
---|
156 | typedef uint32_t VRDPAUDIOFORMAT;
|
---|
157 |
|
---|
158 | /** Constructs 32 bit value for given frequency, number of channel and bits per sample. */
|
---|
159 | #define VRDP_AUDIO_FMT_MAKE(freq, c, bps, s) ((((s) & 0x1) << 28) + (((bps) & 0xFF) << 20) + (((c) & 0xF) << 16) + ((freq) & 0xFFFF))
|
---|
160 |
|
---|
161 | /** Decode frequency. */
|
---|
162 | #define VRDP_AUDIO_FMT_SAMPLE_FREQ(a) ((a) & 0xFFFF)
|
---|
163 | /** Decode number of channels. */
|
---|
164 | #define VRDP_AUDIO_FMT_CHANNELS(a) (((a) >> 16) & 0xF)
|
---|
165 | /** Decode number signess. */
|
---|
166 | #define VRDP_AUDIO_FMT_SIGNED(a) (((a) >> 28) & 0x1)
|
---|
167 | /** Decode number of bits per sample. */
|
---|
168 | #define VRDP_AUDIO_FMT_BITS_PER_SAMPLE(a) (((a) >> 20) & 0xFF)
|
---|
169 | /** Decode number of bytes per sample. */
|
---|
170 | #define VRDP_AUDIO_FMT_BYTES_PER_SAMPLE(a) ((VRDP_AUDIO_FMT_BITS_PER_SAMPLE(a) + 7) / 8)
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * Queues the samples to be sent to client.
|
---|
174 | *
|
---|
175 | * @param hserver Handle of VRDP server instance.
|
---|
176 | * @param pvSamples Address of samples to be sent.
|
---|
177 | * @param cSamples Number of samples.
|
---|
178 | * @param format Encoded audio format for these samples.
|
---|
179 | */
|
---|
180 | VRDPR3DECL(void) VRDPSendAudioSamples (HVRDPSERVER hserver, void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format);
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * Sets sound volume on client.
|
---|
184 | *
|
---|
185 | * @param hserver Handle of VRDP server instance.
|
---|
186 | * @param left 0..0xFFFF volume level for left channel.
|
---|
187 | * @param right 0..0xFFFF volume level for right channel.
|
---|
188 | */
|
---|
189 | VRDPR3DECL(void) VRDPSendAudioVolume (HVRDPSERVER hserver, uint16_t left, uint16_t right);
|
---|
190 |
|
---|
191 |
|
---|
192 | /*
|
---|
193 | * Remote USB backend protocol.
|
---|
194 | */
|
---|
195 |
|
---|
196 | /* The version of Remote USB Protocol. */
|
---|
197 | #define VRDP_USB_VERSION (1)
|
---|
198 |
|
---|
199 | /** USB backend operations. */
|
---|
200 | #define VRDP_USB_REQ_OPEN (0)
|
---|
201 | #define VRDP_USB_REQ_CLOSE (1)
|
---|
202 | #define VRDP_USB_REQ_RESET (2)
|
---|
203 | #define VRDP_USB_REQ_SET_CONFIG (3)
|
---|
204 | #define VRDP_USB_REQ_CLAIM_INTERFACE (4)
|
---|
205 | #define VRDP_USB_REQ_RELEASE_INTERFACE (5)
|
---|
206 | #define VRDP_USB_REQ_INTERFACE_SETTING (6)
|
---|
207 | #define VRDP_USB_REQ_QUEUE_URB (7)
|
---|
208 | #define VRDP_USB_REQ_REAP_URB (8)
|
---|
209 | #define VRDP_USB_REQ_CLEAR_HALTED_EP (9)
|
---|
210 | #define VRDP_USB_REQ_CANCEL_URB (10)
|
---|
211 |
|
---|
212 | /** USB service operations. */
|
---|
213 | #define VRDP_USB_REQ_DEVICE_LIST (11)
|
---|
214 | #define VRDP_USB_REQ_NEGOTIATE (12)
|
---|
215 |
|
---|
216 | /** An operation completion status is a byte. */
|
---|
217 | typedef uint8_t VRDPUSBSTATUS;
|
---|
218 |
|
---|
219 | /** USB device identifier is an 32 bit value. */
|
---|
220 | typedef uint32_t VRDPUSBDEVID;
|
---|
221 |
|
---|
222 | /** Status codes. */
|
---|
223 | #define VRDP_USB_STATUS_SUCCESS ((VRDPUSBSTATUS)0)
|
---|
224 | #define VRDP_USB_STATUS_ACCESS_DENIED ((VRDPUSBSTATUS)1)
|
---|
225 | #define VRDP_USB_STATUS_DEVICE_REMOVED ((VRDPUSBSTATUS)2)
|
---|
226 |
|
---|
227 | /*
|
---|
228 | * Data structures to use with VRDPSendUSBRequest.
|
---|
229 | * The *RET* structures always represent the layout of VRDP data.
|
---|
230 | * The *PARM* structures normally the same as VRDP layout.
|
---|
231 | * However the VRDP_USB_REQ_QUEUE_URB_PARM has a pointer to
|
---|
232 | * URB data in place where actual data will be in VRDP layout.
|
---|
233 | *
|
---|
234 | * Since replies (*RET*) are asynchronous, the 'success'
|
---|
235 | * replies are not required for operations which return
|
---|
236 | * only the status code (VRDPUSBREQRETHDR only):
|
---|
237 | * VRDP_USB_REQ_OPEN
|
---|
238 | * VRDP_USB_REQ_RESET
|
---|
239 | * VRDP_USB_REQ_SET_CONFIG
|
---|
240 | * VRDP_USB_REQ_CLAIM_INTERFACE
|
---|
241 | * VRDP_USB_REQ_RELEASE_INTERFACE
|
---|
242 | * VRDP_USB_REQ_INTERFACE_SETTING
|
---|
243 | * VRDP_USB_REQ_CLEAR_HALTED_EP
|
---|
244 | *
|
---|
245 | */
|
---|
246 |
|
---|
247 | /* VRDP layout has no aligments. */
|
---|
248 | #pragma pack(1)
|
---|
249 |
|
---|
250 | /* Common header for all VRDP USB packets. After the reply hdr follows *PARM* or *RET* data. */
|
---|
251 | typedef struct _VRDPUSBPKTHDR
|
---|
252 | {
|
---|
253 | /* Total length of the reply NOT including the 'length' field. */
|
---|
254 | uint32_t length;
|
---|
255 | /* The operation code for which the reply was sent by the client. */
|
---|
256 | uint8_t code;
|
---|
257 | } VRDPUSBPKTHDR;
|
---|
258 |
|
---|
259 | /* Common header for all return structures. */
|
---|
260 | typedef struct _VRDPUSBREQRETHDR
|
---|
261 | {
|
---|
262 | /* Device status. */
|
---|
263 | VRDPUSBSTATUS status;
|
---|
264 | /* Device id. */
|
---|
265 | VRDPUSBDEVID id;
|
---|
266 | } VRDPUSBREQRETHDR;
|
---|
267 |
|
---|
268 |
|
---|
269 | /* VRDP_USB_REQ_OPEN
|
---|
270 | */
|
---|
271 | typedef struct _VRDP_USB_REQ_OPEN_PARM
|
---|
272 | {
|
---|
273 | uint8_t code;
|
---|
274 | VRDPUSBDEVID id;
|
---|
275 | } VRDP_USB_REQ_OPEN_PARM;
|
---|
276 |
|
---|
277 | typedef struct _VRDP_USB_REQ_OPEN_RET
|
---|
278 | {
|
---|
279 | VRDPUSBREQRETHDR hdr;
|
---|
280 | } VRDP_USB_REQ_OPEN_RET;
|
---|
281 |
|
---|
282 |
|
---|
283 | /* VRDP_USB_REQ_CLOSE
|
---|
284 | */
|
---|
285 | typedef struct _VRDP_USB_REQ_CLOSE_PARM
|
---|
286 | {
|
---|
287 | uint8_t code;
|
---|
288 | VRDPUSBDEVID id;
|
---|
289 | } VRDP_USB_REQ_CLOSE_PARM;
|
---|
290 |
|
---|
291 | /* The close request has no returned data. */
|
---|
292 |
|
---|
293 |
|
---|
294 | /* VRDP_USB_REQ_RESET
|
---|
295 | */
|
---|
296 | typedef struct _VRDP_USB_REQ_RESET_PARM
|
---|
297 | {
|
---|
298 | uint8_t code;
|
---|
299 | VRDPUSBDEVID id;
|
---|
300 | } VRDP_USB_REQ_RESET_PARM;
|
---|
301 |
|
---|
302 | typedef struct _VRDP_USB_REQ_RESET_RET
|
---|
303 | {
|
---|
304 | VRDPUSBREQRETHDR hdr;
|
---|
305 | } VRDP_USB_REQ_RESET_RET;
|
---|
306 |
|
---|
307 |
|
---|
308 | /* VRDP_USB_REQ_SET_CONFIG
|
---|
309 | */
|
---|
310 | typedef struct _VRDP_USB_REQ_SET_CONFIG_PARM
|
---|
311 | {
|
---|
312 | uint8_t code;
|
---|
313 | VRDPUSBDEVID id;
|
---|
314 | uint8_t configuration;
|
---|
315 | } VRDP_USB_REQ_SET_CONFIG_PARM;
|
---|
316 |
|
---|
317 | typedef struct _VRDP_USB_REQ_SET_CONFIG_RET
|
---|
318 | {
|
---|
319 | VRDPUSBREQRETHDR hdr;
|
---|
320 | } VRDP_USB_REQ_SET_CONFIG_RET;
|
---|
321 |
|
---|
322 |
|
---|
323 | /* VRDP_USB_REQ_CLAIM_INTERFACE
|
---|
324 | */
|
---|
325 | typedef struct _VRDP_USB_REQ_CLAIM_INTERFACE_PARM
|
---|
326 | {
|
---|
327 | uint8_t code;
|
---|
328 | VRDPUSBDEVID id;
|
---|
329 | uint8_t iface;
|
---|
330 | } VRDP_USB_REQ_CLAIM_INTERFACE_PARM;
|
---|
331 |
|
---|
332 | typedef struct _VRDP_USB_REQ_CLAIM_INTERFACE_RET
|
---|
333 | {
|
---|
334 | VRDPUSBREQRETHDR hdr;
|
---|
335 | } VRDP_USB_REQ_CLAIM_INTERFACE_RET;
|
---|
336 |
|
---|
337 |
|
---|
338 | /* VRDP_USB_REQ_RELEASE_INTERFACE
|
---|
339 | */
|
---|
340 | typedef struct _VRDP_USB_REQ_RELEASE_INTERFACE_PARM
|
---|
341 | {
|
---|
342 | uint8_t code;
|
---|
343 | VRDPUSBDEVID id;
|
---|
344 | uint8_t iface;
|
---|
345 | } VRDP_USB_REQ_RELEASE_INTERFACE_PARM;
|
---|
346 |
|
---|
347 | typedef struct _VRDP_USB_REQ_RELEASE_INTERFACE_RET
|
---|
348 | {
|
---|
349 | VRDPUSBREQRETHDR hdr;
|
---|
350 | } VRDP_USB_REQ_RELEASE_INTERFACE_RET;
|
---|
351 |
|
---|
352 |
|
---|
353 | /* VRDP_USB_REQ_INTERFACE_SETTING
|
---|
354 | */
|
---|
355 | typedef struct _VRDP_USB_REQ_INTERFACE_SETTING_PARM
|
---|
356 | {
|
---|
357 | uint8_t code;
|
---|
358 | VRDPUSBDEVID id;
|
---|
359 | uint8_t iface;
|
---|
360 | uint8_t setting;
|
---|
361 | } VRDP_USB_REQ_INTERFACE_SETTING_PARM;
|
---|
362 |
|
---|
363 | typedef struct _VRDP_USB_REQ_INTERFACE_SETTING_RET
|
---|
364 | {
|
---|
365 | VRDPUSBREQRETHDR hdr;
|
---|
366 | } VRDP_USB_REQ_INTERFACE_SETTING_RET;
|
---|
367 |
|
---|
368 |
|
---|
369 | /* VRDP_USB_REQ_QUEUE_URB
|
---|
370 | */
|
---|
371 |
|
---|
372 | #define VRDP_USB_TRANSFER_TYPE_CTRL (0)
|
---|
373 | #define VRDP_USB_TRANSFER_TYPE_ISOC (1)
|
---|
374 | #define VRDP_USB_TRANSFER_TYPE_BULK (2)
|
---|
375 | #define VRDP_USB_TRANSFER_TYPE_INTR (3)
|
---|
376 | #define VRDP_USB_TRANSFER_TYPE_MSG (4)
|
---|
377 |
|
---|
378 | #define VRDP_USB_DIRECTION_SETUP (0)
|
---|
379 | #define VRDP_USB_DIRECTION_IN (1)
|
---|
380 | #define VRDP_USB_DIRECTION_OUT (2)
|
---|
381 |
|
---|
382 | typedef struct _VRDP_USB_REQ_QUEUE_URB_PARM
|
---|
383 | {
|
---|
384 | uint8_t code;
|
---|
385 | VRDPUSBDEVID id;
|
---|
386 | uint32_t handle; /* Distinguishes that particular URB. Later used in CancelURB and returned by ReapURB */
|
---|
387 | uint8_t type;
|
---|
388 | uint8_t ep;
|
---|
389 | uint8_t direction;
|
---|
390 | uint32_t urblen; /* Length of the URB. */
|
---|
391 | uint32_t datalen; /* Length of the data. */
|
---|
392 | void *data; /* In RDP layout the data follow. */
|
---|
393 | } VRDP_USB_REQ_QUEUE_URB_PARM;
|
---|
394 |
|
---|
395 | /* The queue URB has no explicit return. The reap URB reply will be
|
---|
396 | * eventually the indirect result.
|
---|
397 | */
|
---|
398 |
|
---|
399 |
|
---|
400 | /* VRDP_USB_REQ_REAP_URB
|
---|
401 | * Notificationg from server to client that server expects an URB
|
---|
402 | * from any device.
|
---|
403 | * Only sent if negotiated URB return method is polling.
|
---|
404 | * Normally, the client will send URBs back as soon as they are ready.
|
---|
405 | */
|
---|
406 | typedef struct _VRDP_USB_REQ_REAP_URB_PARM
|
---|
407 | {
|
---|
408 | uint8_t code;
|
---|
409 | } VRDP_USB_REQ_REAP_URB_PARM;
|
---|
410 |
|
---|
411 |
|
---|
412 | #define VRDP_USB_XFER_OK (0)
|
---|
413 | #define VRDP_USB_XFER_STALL (1)
|
---|
414 | #define VRDP_USB_XFER_DNR (2)
|
---|
415 | #define VRDP_USB_XFER_CRC (3)
|
---|
416 |
|
---|
417 | #define VRDP_USB_REAP_FLAG_CONTINUED (0x0)
|
---|
418 | #define VRDP_USB_REAP_FLAG_LAST (0x1)
|
---|
419 |
|
---|
420 | #define VRDP_USB_REAP_VALID_FLAGS (VRDP_USB_REAP_FLAG_LAST)
|
---|
421 |
|
---|
422 | typedef struct _VRDPUSBREQREAPURBBODY
|
---|
423 | {
|
---|
424 | VRDPUSBDEVID id; /* From which device the URB arrives. */
|
---|
425 | uint8_t flags; /* VRDP_USB_REAP_FLAG_* */
|
---|
426 | uint8_t error; /* VRDP_USB_XFER_* */
|
---|
427 | uint32_t handle; /* Handle of returned URB. Not 0. */
|
---|
428 | uint32_t len; /* Length of data actually transferred. */
|
---|
429 | /* Data follow. */
|
---|
430 | } VRDPUSBREQREAPURBBODY;
|
---|
431 |
|
---|
432 | typedef struct _VRDP_USB_REQ_REAP_URB_RET
|
---|
433 | {
|
---|
434 | /* The REAP URB has no header, only completed URBs are returned. */
|
---|
435 | VRDPUSBREQREAPURBBODY body;
|
---|
436 | /* Another body may follow, depending on flags. */
|
---|
437 | } VRDP_USB_REQ_REAP_URB_RET;
|
---|
438 |
|
---|
439 |
|
---|
440 | /* VRDP_USB_REQ_CLEAR_HALTED_EP
|
---|
441 | */
|
---|
442 | typedef struct _VRDP_USB_REQ_CLEAR_HALTED_EP_PARM
|
---|
443 | {
|
---|
444 | uint8_t code;
|
---|
445 | VRDPUSBDEVID id;
|
---|
446 | uint8_t ep;
|
---|
447 | } VRDP_USB_REQ_CLEAR_HALTED_EP_PARM;
|
---|
448 |
|
---|
449 | typedef struct _VRDP_USB_REQ_CLEAR_HALTED_EP_RET
|
---|
450 | {
|
---|
451 | VRDPUSBREQRETHDR hdr;
|
---|
452 | } VRDP_USB_REQ_CLEAR_HALTED_EP_RET;
|
---|
453 |
|
---|
454 |
|
---|
455 | /* VRDP_USB_REQ_CANCEL_URB
|
---|
456 | */
|
---|
457 | typedef struct _VRDP_USB_REQ_CANCEL_URB_PARM
|
---|
458 | {
|
---|
459 | uint8_t code;
|
---|
460 | VRDPUSBDEVID id;
|
---|
461 | uint32_t handle;
|
---|
462 | } VRDP_USB_REQ_CANCEL_URB_PARM;
|
---|
463 |
|
---|
464 | /* The cancel URB request has no return. */
|
---|
465 |
|
---|
466 |
|
---|
467 | /* VRDP_USB_REQ_DEVICE_LIST
|
---|
468 | *
|
---|
469 | * Server polls USB devices on client by sending this request
|
---|
470 | * periodically. Client sends back a list of all devices
|
---|
471 | * connected to it. Each device is assigned with an identifier,
|
---|
472 | * that is used to distinguish the particular device.
|
---|
473 | */
|
---|
474 | typedef struct _VRDP_USB_REQ_DEVICE_LIST_PARM
|
---|
475 | {
|
---|
476 | uint8_t code;
|
---|
477 | } VRDP_USB_REQ_DEVICE_LIST_PARM;
|
---|
478 |
|
---|
479 | /* Data is a list of the following variable length structures. */
|
---|
480 | typedef struct _VRDPUSBDEVICEDESC
|
---|
481 | {
|
---|
482 | /* Offset of the next structure. 0 if last. */
|
---|
483 | uint16_t oNext;
|
---|
484 |
|
---|
485 | /* Identifier of the device assigned by client. */
|
---|
486 | VRDPUSBDEVID id;
|
---|
487 |
|
---|
488 | /** USB version number. */
|
---|
489 | uint16_t bcdUSB;
|
---|
490 | /** Device class. */
|
---|
491 | uint8_t bDeviceClass;
|
---|
492 | /** Device subclass. */
|
---|
493 | uint8_t bDeviceSubClass;
|
---|
494 | /** Device protocol */
|
---|
495 | uint8_t bDeviceProtocol;
|
---|
496 | /** Vendor ID. */
|
---|
497 | uint16_t idVendor;
|
---|
498 | /** Product ID. */
|
---|
499 | uint16_t idProduct;
|
---|
500 | /** Revision, integer part. */
|
---|
501 | uint16_t bcdRev;
|
---|
502 | /** Manufacturer string. */
|
---|
503 | uint16_t oManufacturer;
|
---|
504 | /** Product string. */
|
---|
505 | uint16_t oProduct;
|
---|
506 | /** Serial number string. */
|
---|
507 | uint16_t oSerialNumber;
|
---|
508 | /** Physical USB port the device is connected to. */
|
---|
509 | uint16_t idPort;
|
---|
510 |
|
---|
511 | } VRDPUSBDEVICEDESC;
|
---|
512 |
|
---|
513 | typedef struct _VRDP_USB_REQ_DEVICE_LIST_RET
|
---|
514 | {
|
---|
515 | VRDPUSBDEVICEDESC body;
|
---|
516 | /* Other devices may follow.
|
---|
517 | * The list ends with (uint16_t)0,
|
---|
518 | * which means that an empty list consists of 2 zero bytes.
|
---|
519 | */
|
---|
520 | } VRDP_USB_REQ_DEVICE_LIST_RET;
|
---|
521 |
|
---|
522 | typedef struct _VRDPUSBREQNEGOTIATEPARM
|
---|
523 | {
|
---|
524 | uint8_t code;
|
---|
525 |
|
---|
526 | /* Remote USB Protocol version. */
|
---|
527 | uint32_t version;
|
---|
528 |
|
---|
529 | } VRDPUSBREQNEGOTIATEPARM;
|
---|
530 |
|
---|
531 | #define VRDP_USB_CAPS_FLAG_ASYNC (0x0)
|
---|
532 | #define VRDP_USB_CAPS_FLAG_POLL (0x1)
|
---|
533 |
|
---|
534 | #define VRDP_USB_CAPS_VALID_FLAGS (VRDP_USB_CAPS_FLAG_POLL)
|
---|
535 |
|
---|
536 | typedef struct _VRDPUSBREQNEGOTIATERET
|
---|
537 | {
|
---|
538 | uint8_t flags;
|
---|
539 | } VRDPUSBREQNEGOTIATERET;
|
---|
540 |
|
---|
541 | #pragma pack()
|
---|
542 |
|
---|
543 |
|
---|
544 | #define VRDP_CLIPBOARD_FORMAT_INVALID (0xFFFFFFFF)
|
---|
545 | #define VRDP_CLIPBOARD_FORMAT_UNICODE_TEXT (0)
|
---|
546 | #define VRDP_CLIPBOARD_FORMAT_BITMAP (1)
|
---|
547 |
|
---|
548 | VRDPR3DECL(void) VRDPSendClipboardData (HVRDPSERVER hserver, uint32_t u32Format, void *pvData, uint32_t cbData);
|
---|
549 |
|
---|
550 | #ifdef VRDP_MC
|
---|
551 | /**
|
---|
552 | * Sends a USB request.
|
---|
553 | *
|
---|
554 | * @param hserver Handle of VRDP server instance.
|
---|
555 | * @param u32ClientId An identifier that allows the server to find the corresponding client.
|
---|
556 | * The identifier is always passed by the server as a parameter
|
---|
557 | * of the FNVRDPUSBCALLBACK. Note that the value is the same as
|
---|
558 | * in the VRDPSERVERCALLBACK functions.
|
---|
559 | * @param pvParm Function specific parameters buffer.
|
---|
560 | * @param cbParm Size of the buffer.
|
---|
561 | */
|
---|
562 | VRDPR3DECL(void) VRDPSendUSBRequest (HVRDPSERVER hserver,
|
---|
563 | uint32_t u32ClientId,
|
---|
564 | void *pvParm,
|
---|
565 | uint32_t cbRarm);
|
---|
566 |
|
---|
567 |
|
---|
568 | /**
|
---|
569 | * Called by the server when a reply is received from a client.
|
---|
570 | *
|
---|
571 | * @param pvCallback Callback specific value returned by VRDPSERVERCALLBACK::pfnInterceptUSB.
|
---|
572 | * @param u32ClientId Identifies the client that sent the reply.
|
---|
573 | * @param u8Code The operation code VRDP_USB_REQ_*.
|
---|
574 | * @param pvRet Points to data received from the client.
|
---|
575 | * @param cbRet Size of the data in bytes.
|
---|
576 | *
|
---|
577 | * @return VBox error code.
|
---|
578 | */
|
---|
579 | typedef DECLCALLBACK(int) FNVRDPUSBCALLBACK (void *pvCallback,
|
---|
580 | uint32_t u32ClientId,
|
---|
581 | uint8_t u8Code,
|
---|
582 | const void *pvRet,
|
---|
583 | uint32_t cbRet);
|
---|
584 |
|
---|
585 | typedef FNVRDPUSBCALLBACK *PFNVRDPUSBCALLBACK;
|
---|
586 |
|
---|
587 | /**
|
---|
588 | * Called by the server when a clipboard data is received from a client.
|
---|
589 | *
|
---|
590 | * @param pvCallback Callback specific value returned by VRDPSERVERCALLBACK::pfnInterceptClipboard.
|
---|
591 | * @param u32ClientId Identifies the client that sent the reply.
|
---|
592 | * @param u32Format The format of data.
|
---|
593 | * @param pvData Points to data received from the client.
|
---|
594 | * @param cbData Size of the data in bytes.
|
---|
595 | *
|
---|
596 | * @return VBox error code.
|
---|
597 | */
|
---|
598 | typedef DECLCALLBACK(int) FNVRDPCLIPBOARDCALLBACK (void *pvCallback,
|
---|
599 | uint32_t u32ClientId,
|
---|
600 | uint32_t u32Format,
|
---|
601 | const void *pvRet,
|
---|
602 | uint32_t cbRet);
|
---|
603 |
|
---|
604 | typedef FNVRDPCLIPBOARDCALLBACK *PFNVRDPCLIPBOARDCALLBACK;
|
---|
605 |
|
---|
606 | #define VRDP_CLIENT_INTERCEPT_AUDIO (0x1)
|
---|
607 | #define VRDP_CLIENT_INTERCEPT_USB (0x2)
|
---|
608 | #define VRDP_CLIENT_INTERCEPT_CLIPBOARD (0x4)
|
---|
609 |
|
---|
610 | typedef struct _VRDPSERVERCALLBACK
|
---|
611 | {
|
---|
612 | /* A client is logging in.
|
---|
613 | *
|
---|
614 | * @param pvUser The callback specific pointer.
|
---|
615 | * @param u32ClientId An unique client identifier generated by the server.
|
---|
616 | * @param pszUser The username.
|
---|
617 | * @param pszPassword The password.
|
---|
618 | * @param pszDomain The domain.
|
---|
619 | *
|
---|
620 | * @return VBox error code.
|
---|
621 | */
|
---|
622 | DECLCALLBACKMEMBER(int, pfnClientLogon) (void *pvUser,
|
---|
623 | uint32_t u32ClientId,
|
---|
624 | const char *pszUser,
|
---|
625 | const char *pszPassword,
|
---|
626 | const char *pszDomain);
|
---|
627 | /* The client has connected.
|
---|
628 | *
|
---|
629 | * @param pvUser The callback specific pointer.
|
---|
630 | * @param u32ClientId An unique client identifier generated by the server.
|
---|
631 | */
|
---|
632 | DECLCALLBACKMEMBER(void, pfnClientConnect) (void *pvUser,
|
---|
633 | uint32_t u32ClientId);
|
---|
634 | /* The client has been disconnected.
|
---|
635 | *
|
---|
636 | * @param pvUser The callback specific pointer.
|
---|
637 | * @param u32ClientId An unique client identifier generated by the server.
|
---|
638 | * @param fu32Intercepted What was intercepted by the client (VRDP_CLIENT_INTERCEPT_*).
|
---|
639 | */
|
---|
640 | DECLCALLBACKMEMBER(void, pfnClientDisconnect) (void *pvUser,
|
---|
641 | uint32_t u32ClientId,
|
---|
642 | uint32_t fu32Intercepted);
|
---|
643 | /* The client supports audio channel.
|
---|
644 | */
|
---|
645 | DECLCALLBACKMEMBER(void, pfnInterceptAudio) (void *pvUser,
|
---|
646 | uint32_t u32ClientId);
|
---|
647 | /* The client supports USB channel.
|
---|
648 | */
|
---|
649 | DECLCALLBACKMEMBER(void, pfnInterceptUSB) (void *pvUser,
|
---|
650 | uint32_t u32ClientId,
|
---|
651 | PFNVRDPUSBCALLBACK *ppfn,
|
---|
652 | void **ppv);
|
---|
653 | /* The client supports clipboard channel.
|
---|
654 | */
|
---|
655 | DECLCALLBACKMEMBER(void, pfnInterceptClipboard) (void *pvUser,
|
---|
656 | uint32_t u32ClientId,
|
---|
657 | PFNVRDPCLIPBOARDCALLBACK *ppfn,
|
---|
658 | void **ppv);
|
---|
659 | } VRDPSERVERCALLBACK;
|
---|
660 | #else
|
---|
661 | /**
|
---|
662 | * Sends a USB request.
|
---|
663 | *
|
---|
664 | * @param hserver Handle of VRDP server instance.
|
---|
665 | * @param pvParm Function specific parameters buffer.
|
---|
666 | * @param cbParm Size of the buffer.
|
---|
667 | * @param pvRet Function specific returned data buffer.
|
---|
668 | * @param cbRet Size of the buffer.
|
---|
669 | * @param prc VBox return code.
|
---|
670 | */
|
---|
671 | VRDPR3DECL(void) VRDPSendUSBRequest (HVRDPSERVER hserver, void *pvParm, uint32_t cbRarm);
|
---|
672 |
|
---|
673 |
|
---|
674 | typedef DECLCALLBACK(int) FNVRDPUSBCALLBACK (void *pv, uint8_t code, void *pvRet, uint32_t cbRet);
|
---|
675 | typedef FNVRDPUSBCALLBACK *PFNVRDPUSBCALLBACK;
|
---|
676 |
|
---|
677 | typedef DECLCALLBACK(int) FNVRDPCLIPBOARDCALLBACK (void *pv, uint32_t u32Format, void *pvData, uint32_t cbData);
|
---|
678 | typedef FNVRDPCLIPBOARDCALLBACK *PFNVRDPCLIPBOARDCALLBACK;
|
---|
679 |
|
---|
680 | typedef struct _VRDPSERVERCALLBACK
|
---|
681 | {
|
---|
682 | DECLCALLBACKMEMBER(int, pfnClientLogon) (void *pvUser, const char *pszUser, const char *pszPassword, const char *pszDomain);
|
---|
683 | DECLCALLBACKMEMBER(void, pfnClientConnect) (void *pvUser, uint32_t fu32SupportedOrders);
|
---|
684 | DECLCALLBACKMEMBER(void, pfnClientDisconnect) (void *pvUser);
|
---|
685 | DECLCALLBACKMEMBER(void, pfnInterceptAudio) (void *pvUser, bool fKeepHostAudio);
|
---|
686 | DECLCALLBACKMEMBER(void, pfnInterceptUSB) (void *pvUser, PFNVRDPUSBCALLBACK *ppfn, void **ppv);
|
---|
687 | DECLCALLBACKMEMBER(void, pfnInterceptClipboard) (void *pvUser, PFNVRDPCLIPBOARDCALLBACK *ppfn, void **ppv);
|
---|
688 | } VRDPSERVERCALLBACK;
|
---|
689 | #endif /* VRDP_MC */
|
---|
690 |
|
---|
691 | /**
|
---|
692 | * Set a callback pointers table that will be called by the server in certain situations.
|
---|
693 | *
|
---|
694 | * @param hserver Handle of VRDP server instance.
|
---|
695 | * @param pCallback Pointer to VRDPSERVERCALLBACK structure with function pointers.
|
---|
696 | * @param pvUser An pointer to be passed to the callback functions.
|
---|
697 | */
|
---|
698 | VRDPR3DECL(void) VRDPSetCallback (HVRDPSERVER hserver, VRDPSERVERCALLBACK *pCallback, void *pvUser);
|
---|
699 |
|
---|
700 | /** Indexes of information values. */
|
---|
701 |
|
---|
702 | /** Whether a client is connected at the moment.
|
---|
703 | * uint32_t
|
---|
704 | */
|
---|
705 | #define VRDP_QI_ACTIVE (0)
|
---|
706 |
|
---|
707 | /** How many times a client connected up to current moment.
|
---|
708 | * uint32_t
|
---|
709 | */
|
---|
710 | #define VRDP_QI_NUMBER_OF_CLIENTS (1)
|
---|
711 |
|
---|
712 | /** When last connection was established.
|
---|
713 | * int64_t time in milliseconds since 1970-01-01 00:00:00 UTC
|
---|
714 | */
|
---|
715 | #define VRDP_QI_BEGIN_TIME (2)
|
---|
716 |
|
---|
717 | /** When last connection was terminated or current time if connection still active.
|
---|
718 | * int64_t time in milliseconds since 1970-01-01 00:00:00 UTC
|
---|
719 | */
|
---|
720 | #define VRDP_QI_END_TIME (3)
|
---|
721 |
|
---|
722 | /** How many bytes were sent in last (current) connection.
|
---|
723 | * uint64_t
|
---|
724 | */
|
---|
725 | #define VRDP_QI_BYTES_SENT (4)
|
---|
726 |
|
---|
727 | /** How many bytes were sent in all connections.
|
---|
728 | * uint64_t
|
---|
729 | */
|
---|
730 | #define VRDP_QI_BYTES_SENT_TOTAL (5)
|
---|
731 |
|
---|
732 | /** How many bytes were received in last (current) connection.
|
---|
733 | * uint64_t
|
---|
734 | */
|
---|
735 | #define VRDP_QI_BYTES_RECEIVED (6)
|
---|
736 |
|
---|
737 | /** How many bytes were received in all connections.
|
---|
738 | * uint64_t
|
---|
739 | */
|
---|
740 | #define VRDP_QI_BYTES_RECEIVED_TOTAL (7)
|
---|
741 |
|
---|
742 | /** Login user name supplied by the client.
|
---|
743 | * UTF8 nul terminated string.
|
---|
744 | */
|
---|
745 | #define VRDP_QI_USER (8)
|
---|
746 |
|
---|
747 | /** Login domain supplied by the client.
|
---|
748 | * UTF8 nul terminated string.
|
---|
749 | */
|
---|
750 | #define VRDP_QI_DOMAIN (9)
|
---|
751 |
|
---|
752 | /** The client name supplied by the client.
|
---|
753 | * UTF8 nul terminated string.
|
---|
754 | */
|
---|
755 | #define VRDP_QI_CLIENT_NAME (10)
|
---|
756 |
|
---|
757 | /** IP address of the client.
|
---|
758 | * UTF8 nul terminated string.
|
---|
759 | */
|
---|
760 | #define VRDP_QI_CLIENT_IP (11)
|
---|
761 |
|
---|
762 | /** The client software version number.
|
---|
763 | * uint32_t.
|
---|
764 | */
|
---|
765 | #define VRDP_QI_CLIENT_VERSION (12)
|
---|
766 |
|
---|
767 | /** Public key exchange method used when connection was established.
|
---|
768 | * Values: 0 - RDP4 public key exchange scheme.
|
---|
769 | * 1 - X509 sertificates were sent to client.
|
---|
770 | * uint32_t.
|
---|
771 | */
|
---|
772 | #define VRDP_QI_ENCRYPTION_STYLE (13)
|
---|
773 |
|
---|
774 | /**
|
---|
775 | * Query various information from the VRDP server.
|
---|
776 | *
|
---|
777 | * @param index VRDP_QI_* identifier of information to be returned.
|
---|
778 | * @param pvBuffer Address of memory buffer to which the information must be written.
|
---|
779 | * @param cbBuffer Size of the memory buffer in bytes.
|
---|
780 | * @param pcbOut Size in bytes of returned information value.
|
---|
781 | *
|
---|
782 | * @remark The caller must check the *pcbOut. 0 there means no information was returned.
|
---|
783 | * A value greater than cbBuffer means that information is too big to fit in the
|
---|
784 | * buffer, in that case no information was placed to the buffer.
|
---|
785 | */
|
---|
786 | VRDPR3DECL(void) VRDPQueryInfo (HVRDPSERVER hserver, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
|
---|
787 |
|
---|
788 | __END_DECLS
|
---|
789 |
|
---|
790 | /** @} */
|
---|
791 |
|
---|
792 | #endif /* __VBox_vrdpapi_h__ */
|
---|
793 |
|
---|