1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox Remote USB backend
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_REMOTEUSBBACKEND
|
---|
19 | #define ____H_REMOTEUSBBACKEND
|
---|
20 |
|
---|
21 | #include "RemoteUSBDeviceImpl.h"
|
---|
22 |
|
---|
23 | #include <VBox/vrdpapi.h>
|
---|
24 | #include <VBox/vrdpusb.h>
|
---|
25 |
|
---|
26 | #include <iprt/critsect.h>
|
---|
27 |
|
---|
28 | //typedef enum
|
---|
29 | //{
|
---|
30 | // RDLIdle = 0,
|
---|
31 | // RDLReqSent,
|
---|
32 | // RDLObtained
|
---|
33 | //} RDLState;
|
---|
34 |
|
---|
35 | DECLCALLBACK(int) USBClientResponseCallback (void *pv, uint32_t u32ClientId, uint8_t code, const void *pvRet, uint32_t cbRet);
|
---|
36 |
|
---|
37 | /* How many remote devices can be attached to a remote client.
|
---|
38 | * Normally a client computer has 2-8 physical USB ports, so 16 devices
|
---|
39 | * should be usually enough.
|
---|
40 | */
|
---|
41 | #define VRDP_MAX_USB_DEVICES_PER_CLIENT (16)
|
---|
42 |
|
---|
43 | class RemoteUSBBackendListable
|
---|
44 | {
|
---|
45 | public:
|
---|
46 | RemoteUSBBackendListable *pNext;
|
---|
47 | RemoteUSBBackendListable *pPrev;
|
---|
48 |
|
---|
49 | RemoteUSBBackendListable() : pNext (NULL), pPrev (NULL) {};
|
---|
50 | };
|
---|
51 |
|
---|
52 | class RemoteUSBBackend: public RemoteUSBBackendListable
|
---|
53 | {
|
---|
54 | public:
|
---|
55 | RemoteUSBBackend(Console *console, ConsoleVRDPServer *server, uint32_t u32ClientId);
|
---|
56 | ~RemoteUSBBackend();
|
---|
57 |
|
---|
58 | uint32_t ClientId (void) { return mu32ClientId; }
|
---|
59 |
|
---|
60 | void AddRef (void);
|
---|
61 | void Release (void);
|
---|
62 |
|
---|
63 | REMOTEUSBCALLBACK *GetBackendCallbackPointer (void) { return &mCallback; }
|
---|
64 |
|
---|
65 | void NotifyDelete (void);
|
---|
66 |
|
---|
67 | void PollRemoteDevices (void);
|
---|
68 |
|
---|
69 | public: /* Functions for internal use. */
|
---|
70 | ConsoleVRDPServer *VRDPServer (void) { return mServer; };
|
---|
71 |
|
---|
72 | bool pollingEnabledURB (void) { return mfPollURB; }
|
---|
73 |
|
---|
74 | int saveDeviceList (const void *pvList, uint32_t cbList);
|
---|
75 |
|
---|
76 | int negotiateResponse (const VRDPUSBREQNEGOTIATERET *pret, uint32_t cbRet);
|
---|
77 |
|
---|
78 | int reapURB (const void *pvBody, uint32_t cbBody);
|
---|
79 |
|
---|
80 | void request (void);
|
---|
81 | void release (void);
|
---|
82 |
|
---|
83 | PREMOTEUSBDEVICE deviceFromId (VRDPUSBDEVID id);
|
---|
84 |
|
---|
85 | void addDevice (PREMOTEUSBDEVICE pDevice);
|
---|
86 | void removeDevice (PREMOTEUSBDEVICE pDevice);
|
---|
87 |
|
---|
88 | bool addUUID (const Guid *pUuid);
|
---|
89 | bool findUUID (const Guid *pUuid);
|
---|
90 | void removeUUID (const Guid *pUuid);
|
---|
91 |
|
---|
92 | private:
|
---|
93 | Console *mConsole;
|
---|
94 | ConsoleVRDPServer *mServer;
|
---|
95 |
|
---|
96 | int cRefs;
|
---|
97 |
|
---|
98 | uint32_t mu32ClientId;
|
---|
99 |
|
---|
100 | RTCRITSECT mCritsect;
|
---|
101 |
|
---|
102 | REMOTEUSBCALLBACK mCallback;
|
---|
103 |
|
---|
104 | bool mfHasDeviceList;
|
---|
105 |
|
---|
106 | void *mpvDeviceList;
|
---|
107 | uint32_t mcbDeviceList;
|
---|
108 |
|
---|
109 | typedef enum {
|
---|
110 | PollRemoteDevicesStatus_Negotiate,
|
---|
111 | PollRemoteDevicesStatus_WaitNegotiateResponse,
|
---|
112 | PollRemoteDevicesStatus_SendRequest,
|
---|
113 | PollRemoteDevicesStatus_WaitResponse,
|
---|
114 | PollRemoteDevicesStatus_Dereferenced
|
---|
115 | } PollRemoteDevicesStatus;
|
---|
116 |
|
---|
117 | PollRemoteDevicesStatus menmPollRemoteDevicesStatus;
|
---|
118 |
|
---|
119 | bool mfPollURB;
|
---|
120 |
|
---|
121 | PREMOTEUSBDEVICE mpDevices;
|
---|
122 |
|
---|
123 | bool mfWillBeDeleted;
|
---|
124 |
|
---|
125 | Guid aGuids[VRDP_MAX_USB_DEVICES_PER_CLIENT];
|
---|
126 |
|
---|
127 | /* VRDP_USB_VERSION_2: the client version. */
|
---|
128 | uint32_t mClientVersion;
|
---|
129 | };
|
---|
130 |
|
---|
131 | #endif /* ____H_REMOTEUSBBACKEND */
|
---|
132 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|