- Timestamp:
- Aug 8, 2013 8:09:42 PM (11 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp
r45415 r47620 50 50 * 51 51 * @returns VBox status code 52 * @param puClientId Where to put the client id on success. The client id52 * @param puClientId Where to put The client ID on success. The client ID 53 53 * must be passed to all the other calls to the service. 54 54 */ … … 77 77 * 78 78 * @returns VBox status code. 79 * @param uClientId The client idreturned by VbglR3GuestCtrlConnect().79 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect(). 80 80 */ 81 81 VBGLR3DECL(int) VbglR3GuestCtrlDisconnect(uint32_t uClientId) … … 97 97 * 98 98 * @returns VBox status code. 99 * @param uClientId The client idreturned by VbglR3GuestCtrlConnect().99 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect(). 100 100 * @param puMsg Where to store the message id. 101 101 * @param puNumParms Where to store the number of parameters which will be received … … 134 134 * Asks the host guest control service to set a command filter to this 135 135 * client so that it only will receive certain commands in the future. 136 * The filter(s) are a bitmask for the context IDs, served from the host. 136 137 * 137 138 * @return IPRT status code. 138 * @param uClientId The client idreturned by VbglR3GuestCtrlConnect().139 * @param uFilterAdd Filter mask to add.140 * @param uFilterRemove Filter mask to remove.141 */ 142 VBGLR3DECL(int) VbglR3GuestCtrlMsg SetFilter(uint32_t uClientId,139 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect(). 140 * @param uFilterAdd Context ID filter mask to add. 141 * @param uFilterRemove Context ID filter mask to remove. 142 */ 143 VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, 143 144 uint32_t uFilterAdd, uint32_t uFilterRemove) 144 145 { 145 HGCMMsgCmd SetFilterMsg;146 HGCMMsgCmdFilterSet Msg; 146 147 147 148 Msg.hdr.result = VERR_WRONG_ORDER; 148 149 Msg.hdr.u32ClientID = uClientId; 149 Msg.hdr.u32Function = GUEST_MSG_FILTER ; /* Tell the host we want to set a filter. */150 Msg.hdr.cParms = 2;150 Msg.hdr.u32Function = GUEST_MSG_FILTER_SET; /* Tell the host we want to set a filter. */ 151 Msg.hdr.cParms = 3; 151 152 152 153 VbglHGCMParmUInt32Set(&Msg.add, uFilterAdd); 153 154 VbglHGCMParmUInt32Set(&Msg.remove, uFilterRemove); 155 VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */); 156 157 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 158 if (RT_SUCCESS(rc)) 159 rc = Msg.hdr.result; 160 return rc; 161 } 162 163 164 /** 165 * Disables a previously set message filter. 166 * 167 * @return IPRT status code. 168 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect(). 169 */ 170 VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterUnset(uint32_t uClientId) 171 { 172 HGCMMsgCmdFilterUnset Msg; 173 174 Msg.hdr.result = VERR_WRONG_ORDER; 175 Msg.hdr.u32ClientID = uClientId; 176 Msg.hdr.u32Function = GUEST_MSG_FILTER_UNSET; /* Tell the host we want to unset the filter. */ 177 Msg.hdr.cParms = 1; 178 179 VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */); 154 180 155 181 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); … … 165 191 * 166 192 * @return IPRT status code. 167 * @param uClientId The client idreturned by VbglR3GuestCtrlConnect().193 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect(). 168 194 */ 169 195 VBGLR3DECL(int) VbglR3GuestCtrlMsgSkip(uint32_t uClientId) … … 175 201 Msg.hdr.u32Function = GUEST_MSG_SKIP; /* Tell the host we want to skip 176 202 the current assigned command. */ 177 Msg.hdr.cParms = 0; /* No parameters needed. */ 203 Msg.hdr.cParms = 1; 204 205 VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */); 178 206 179 207 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); … … 189 217 * 190 218 * @returns VBox status code. 191 * @param uClientId The client idreturned by VbglR3GuestCtrlConnect().219 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect(). 192 220 */ 193 221 VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(uint32_t uClientId) -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r47551 r47620 1080 1080 if (RT_SUCCESS(rc)) 1081 1081 { 1082 /* Set session filter. */ 1082 /* Set session filter. This prevents the guest control 1083 * host service to send messages which belong to another 1084 * session we don't want to handle. */ 1083 1085 uint32_t uFilterAdd = 1084 1086 VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(pSession->StartupInfo.uSessionID); 1085 1086 rc = VbglR3GuestCtrlMsgSetFilter(uClientID, uFilterAdd, 0 /* Filter remove */); 1087 VBoxServiceVerbose(3, "Setting message filterAdd=%RU32 returned %Rrc\n", 1087 uFilterAdd |= 0x7FFFFFF; /* We only want to filter for session IDs. */ 1088 1089 rc = VbglR3GuestCtrlMsgFilterSet(uClientID, uFilterAdd, 0 /* Filter remove */); 1090 VBoxServiceVerbose(3, "Setting message filterAdd=0x%x returned %Rrc\n", 1088 1091 uFilterAdd, rc); 1089 1092 -
trunk/src/VBox/HostServices/GuestControl/service.cpp
r47488 r47620 563 563 return false; 564 564 565 #ifdef DEBUG_andy 566 LogFlowFunc(("[Client %RU32] mFlags=%x, mContextID=%RU32, mContextFilter=%x, filterRes=%x, sessionID=%RU32\n", 567 mID, mFlags, pHostCmd->mContextID, mContextFilter, 568 pHostCmd->mContextID & mContextFilter, VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCmd->mContextID))); 565 #ifdef DEBUG 566 LogFlowFunc(("[Client %RU32] mFlags=0x%x, mContextID=%RU32 (session %RU32), mContextFilter=0x%x (result=%x -> %RTbool)\n", 567 mID, mFlags, pHostCmd->mContextID, 568 VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCmd->mContextID), 569 mContextFilter, 570 pHostCmd->mContextID & pHostCmd->mContextID, 571 (pHostCmd->mContextID & mContextFilter) == pHostCmd->mContextID)); 569 572 #endif 570 573 /* 571 * If a sesseion filter is set, only obey those sessions we're interested in. 574 * If a sesseion filter is set, only obey those commands we're interested in 575 * by applying our context ID filter mask and compare the result with the 576 * original context ID. 572 577 */ 573 bool fWant = false;578 bool fWant; 574 579 if (mFlags & CLIENTSTATE_FLAG_CONTEXTFILTER) 575 580 { 576 if ((pHostCmd->mContextID & mContextFilter) == mContextFilter)577 fWant = true;581 fWant = 582 (pHostCmd->mContextID & mContextFilter) == pHostCmd->mContextID; 578 583 } 579 584 else /* Client is interested in all commands. */ … … 995 1000 int clientDisconnect(uint32_t u32ClientID, void *pvClient); 996 1001 int clientGetCommand(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 997 int clientSetMsgFilter(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 1002 int clientSetMsgFilterSet(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 1003 int clientSetMsgFilterUnset(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 998 1004 int clientSkipMsg(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 999 1005 int cancelHostCmd(uint32_t u32ContextID); … … 1136 1142 } 1137 1143 1138 int Service::clientSetMsgFilter (uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle,1139 uint32_t cParms, VBOXHGCMSVCPARM paParms[])1144 int Service::clientSetMsgFilterSet(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, 1145 uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 1140 1146 { 1141 1147 /* … … 1149 1155 return VERR_NOT_FOUND; /* Should never happen. */ 1150 1156 1151 if (cParms != 2)1157 if (cParms != 3) 1152 1158 return VERR_INVALID_PARAMETER; 1153 1159 … … 1166 1172 clientState.mContextFilter &= ~uMaskRemove; 1167 1173 1168 LogFlowFunc((" Client ID=%RU32 now has filter=%x enabled (flags=%x, maskAdd=%x, maskRemove=%x)\n",1174 LogFlowFunc(("[Client %RU32] Setting message filter=0x%x set (flags=0x%x, maskAdd=0x%x, maskRemove=0x%x)\n", 1169 1175 u32ClientID, clientState.mContextFilter, clientState.mFlags, 1170 1176 uMaskAdd, uMaskRemove)); … … 1172 1178 1173 1179 return rc; 1180 } 1181 1182 int Service::clientSetMsgFilterUnset(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, 1183 uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 1184 { 1185 /* 1186 * Lookup client in our list so that we can assign the context ID of 1187 * a command to that client. 1188 */ 1189 ClientStateMapIter itClientState = mClientStateMap.find(u32ClientID); 1190 AssertMsg(itClientState != mClientStateMap.end(), ("Client with ID=%RU32 not found when it should be present\n", 1191 u32ClientID)); 1192 if (itClientState == mClientStateMap.end()) 1193 return VERR_NOT_FOUND; /* Should never happen. */ 1194 1195 if (cParms != 1) 1196 return VERR_INVALID_PARAMETER; 1197 1198 ClientState &clientState = itClientState->second; 1199 1200 clientState.mFlags &= ~CLIENTSTATE_FLAG_CONTEXTFILTER; 1201 clientState.mContextFilter = 0; 1202 1203 LogFlowFunc(("[Client %RU32} Unset message filter\n", u32ClientID)); 1204 return VINF_SUCCESS; 1174 1205 } 1175 1206 … … 1187 1218 return VERR_NOT_FOUND; /* Should never happen. */ 1188 1219 1189 if (cParms != 0)1220 if (cParms != 1) 1190 1221 return VERR_INVALID_PARAMETER; 1191 1222 … … 1325 1356 LogFlowFunc(("Waking up client ID=%RU32 failed with rc=%Rrc\n", 1326 1357 itClientState->first, rc2)); 1327 #ifdef DEBUG _andy1358 #ifdef DEBUG 1328 1359 uClientsWokenUp++; 1329 1360 #endif … … 1333 1364 } 1334 1365 1335 #ifdef DEBUG _andy1366 #ifdef DEBUG 1336 1367 LogFlowFunc(("%RU32 clients have been woken up\n", uClientsWokenUp)); 1337 1368 #endif … … 1385 1416 * Since VBox 4.3+. 1386 1417 */ 1387 case GUEST_MSG_FILTER: 1388 LogFlowFunc(("[Client %RU32] GUEST_MSG_FILTER\n", u32ClientID)); 1389 rc = clientSetMsgFilter(u32ClientID, callHandle, cParms, paParms); 1418 case GUEST_MSG_FILTER_SET: 1419 LogFlowFunc(("[Client %RU32] GUEST_MSG_FILTER_SET\n", u32ClientID)); 1420 rc = clientSetMsgFilterSet(u32ClientID, callHandle, cParms, paParms); 1421 break; 1422 1423 /* 1424 * Unsetting the message filter flag. 1425 */ 1426 case GUEST_MSG_FILTER_UNSET: 1427 LogFlowFunc(("[Client %RU32] GUEST_MSG_FILTER_UNSET\n", u32ClientID)); 1428 rc = clientSetMsgFilterUnset(u32ClientID, callHandle, cParms, paParms); 1390 1429 break; 1391 1430
Note:
See TracChangeset
for help on using the changeset viewer.