VirtualBox

Ignore:
Timestamp:
Aug 8, 2013 8:09:42 PM (11 years ago)
Author:
vboxsync
Message:

GuestCtrl: Fixed per-session command filtering, added command to disable the filter again.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestControl/service.cpp

    r47488 r47620  
    563563            return false;
    564564
    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));
    569572#endif
    570573        /*
    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.
    572577         */
    573         bool fWant = false;
     578        bool fWant;
    574579        if (mFlags & CLIENTSTATE_FLAG_CONTEXTFILTER)
    575580        {
    576             if ((pHostCmd->mContextID & mContextFilter) == mContextFilter)
    577                 fWant = true;
     581            fWant =
     582                (pHostCmd->mContextID & mContextFilter) == pHostCmd->mContextID;
    578583        }
    579584        else /* Client is interested in all commands. */
     
    9951000    int clientDisconnect(uint32_t u32ClientID, void *pvClient);
    9961001    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[]);
    9981004    int clientSkipMsg(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
    9991005    int cancelHostCmd(uint32_t u32ContextID);
     
    11361142}
    11371143
    1138 int Service::clientSetMsgFilter(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle,
    1139                                 uint32_t cParms, VBOXHGCMSVCPARM paParms[])
     1144int Service::clientSetMsgFilterSet(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle,
     1145                                   uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    11401146{
    11411147    /*
     
    11491155        return VERR_NOT_FOUND; /* Should never happen. */
    11501156
    1151     if (cParms != 2)
     1157    if (cParms != 3)
    11521158        return VERR_INVALID_PARAMETER;
    11531159
     
    11661172            clientState.mContextFilter &= ~uMaskRemove;
    11671173
    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",
    11691175                     u32ClientID, clientState.mContextFilter, clientState.mFlags,
    11701176                     uMaskAdd, uMaskRemove));
     
    11721178
    11731179    return rc;
     1180}
     1181
     1182int 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;
    11741205}
    11751206
     
    11871218        return VERR_NOT_FOUND; /* Should never happen. */
    11881219
    1189     if (cParms != 0)
     1220    if (cParms != 1)
    11901221        return VERR_INVALID_PARAMETER;
    11911222
     
    13251356                    LogFlowFunc(("Waking up client ID=%RU32 failed with rc=%Rrc\n",
    13261357                                 itClientState->first, rc2));
    1327 #ifdef DEBUG_andy
     1358#ifdef DEBUG
    13281359                uClientsWokenUp++;
    13291360#endif
     
    13331364        }
    13341365
    1335 #ifdef DEBUG_andy
     1366#ifdef DEBUG
    13361367        LogFlowFunc(("%RU32 clients have been woken up\n", uClientsWokenUp));
    13371368#endif
     
    13851416                 * Since VBox 4.3+.
    13861417                 */
    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);
    13901429                    break;
    13911430
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette