VirtualBox

Changeset 53067 in vbox for trunk/src


Ignore:
Timestamp:
Oct 15, 2014 1:10:29 PM (10 years ago)
Author:
vboxsync
Message:

Add possibility to configure a single USB traffic sniffer for a complete roothub (must be configured through extra data)

Location:
trunk/src/VBox/Devices/USB
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp

    r53062 r53067  
    499499#endif
    500500
     501    /* If there is a sniffer on the roothub record the URB there. */
     502    if (pRh->hSniffer != VUSBSNIFFER_NIL)
     503    {
     504        int rc = VUSBSnifferRecordEvent(pRh->hSniffer, pUrb, VUSBSNIFFEREVENT_SUBMIT);
     505        if (RT_FAILURE(rc))
     506            LogRel(("VUSB: Capturing URB submit event on the root hub failed with %Rrc\n", rc));
     507    }
     508
    501509    /*
    502510     * The device was resolved when we allocated the URB.
     
    888896        pRh->Hub.pszName = NULL;
    889897    }
     898    if (pRh->hSniffer != VUSBSNIFFER_NIL)
     899        VUSBSnifferDestroy(pRh->hSniffer);
    890900    RTCritSectDelete(&pRh->CritSectDevices);
    891901    RTCritSectDelete(&pRh->CritSectFreeUrbs);
     
    907917     * Validate configuration.
    908918     */
    909     if (!CFGMR3AreValuesValid(pCfg, "\0"))
     919    if (!CFGMR3AreValuesValid(pCfg, "CaptureFilename\0"))
    910920        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    911921
     
    927937    if (RT_FAILURE(rc))
    928938        return rc;
     939
     940    char *pszCaptureFilename = NULL;
     941    rc = CFGMR3QueryStringAlloc(pCfg, "CaptureFilename", &pszCaptureFilename);
     942    if (   RT_FAILURE(rc)
     943        && rc != VERR_CFGM_VALUE_NOT_FOUND)
     944        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
     945                                   N_("Configuration error: Failed to query value of \"CaptureFilename\""));
    929946
    930947    /*
     
    958975    pThis->IRhConnector.pfnAttachDevice = vusbRhAttachDevice;
    959976    pThis->IRhConnector.pfnDetachDevice = vusbRhDetachDevice;
     977    pThis->hSniffer                     = VUSBSNIFFER_NIL;
    960978    /*
    961979     * Resolve interface(s).
     
    977995    pThis->fHcVersions = pThis->pIRhPort->pfnGetUSBVersions(pThis->pIRhPort);
    978996    Log(("vusbRhConstruct: fHcVersions=%u\n", pThis->fHcVersions));
     997
     998    if (pszCaptureFilename)
     999    {
     1000        rc = VUSBSnifferCreate(&pThis->hSniffer, 0, pszCaptureFilename, NULL);
     1001        if (RT_FAILURE(rc))
     1002            return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
     1003                                       N_("Failed to create USB sniffer instance"));
     1004
     1005        MMR3HeapFree(pszCaptureFilename);
     1006    }
    9791007
    9801008    /*
  • trunk/src/VBox/Devices/USB/VUSBInternal.h

    r53062 r53067  
    383383    /** Chain of free URBs. (Singly linked) */
    384384    PVUSBURB                pFreeUrbs;
     385    /** Sniffer instance for the root hub. */
     386    VUSBSNIFFER             hSniffer;
    385387    /** The number of URBs in the pool. */
    386388    uint32_t                cUrbsInPool;
     
    388390    uint32_t                fHcVersions;
    389391#ifdef VBOX_WITH_STATISTICS
    390 #if HC_ARCH_BITS == 32
    391     uint32_t                Alignment2; /**< Counters must be 64-bit aligned. */
    392 #endif
    393392    VUSBROOTHUBTYPESTATS    Total;
    394393    VUSBROOTHUBTYPESTATS    aTypes[VUSBXFERTYPE_MSG];
  • trunk/src/VBox/Devices/USB/VUSBUrb.cpp

    r53062 r53067  
    10281028    PVUSBROOTHUB pRh = vusbDevGetRh(pUrb->VUsb.pDev);
    10291029    AssertPtrReturnVoid(pRh);
     1030
     1031    /* If there is a sniffer on the roothub record the completed URB there too. */
     1032    if (pRh->hSniffer != VUSBSNIFFER_NIL)
     1033    {
     1034        int rc = VUSBSnifferRecordEvent(pRh->hSniffer, pUrb,
     1035                                          pUrb->enmStatus == VUSBSTATUS_OK
     1036                                        ? VUSBSNIFFEREVENT_COMPLETE
     1037                                        : VUSBSNIFFEREVENT_ERROR_COMPLETE);
     1038        if (RT_FAILURE(rc))
     1039            LogRel(("VUSB: Capturing URB completion event on the root hub failed with %Rrc\n", rc));
     1040    }
     1041
    10301042    if (pUrb->enmType != VUSBXFERTYPE_MSG)
    10311043    {
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