- Timestamp:
- Oct 15, 2014 7:30:08 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 96577
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/VUSBSniffer.cpp
r53071 r53072 27 27 #include <iprt/system.h> 28 28 #include <iprt/semaphore.h> 29 #include <iprt/time.h> 29 30 30 31 #include "VUSBSniffer.h" … … 320 321 321 322 /** 322 * Commits the current block to the capture file.323 * Aligns the current block data to a 32bit boundary. 323 324 * 324 325 * @returns VBox status code. 325 326 * @param pThis The VUSB sniffer instance. 326 327 */ 327 static int vusbSnifferBlock Commit(PVUSBSNIFFERINT pThis)328 static int vusbSnifferBlockAlign(PVUSBSNIFFERINT pThis) 328 329 { 329 330 int rc = VINF_SUCCESS; 330 331 331 Assert Ptr(pThis->pBlockHdr);332 Assert(pThis->cbBlockCur); 332 333 333 334 /* Pad to 32bits. */ … … 339 340 rc = vusbSnifferBlockAddData(pThis, abPad, cbPad); 340 341 342 return rc; 343 } 344 345 /** 346 * Commits the current block to the capture file. 347 * 348 * @returns VBox status code. 349 * @param pThis The VUSB sniffer instance. 350 */ 351 static int vusbSnifferBlockCommit(PVUSBSNIFFERINT pThis) 352 { 353 int rc = VINF_SUCCESS; 354 355 AssertPtr(pThis->pBlockHdr); 356 357 rc = vusbSnifferBlockAlign(pThis); 341 358 if (RT_SUCCESS(rc)) 342 359 { … … 407 424 rc = vusbSnifferBlockAddData(pThis, pvOption, cbOption); 408 425 if (RT_SUCCESS(rc)) 409 { 410 /* Pad to 32bits. */ 411 uint8_t abPad[3] = { 0 }; 412 uint32_t cbPad = RT_ALIGN_32(cbOption, 4) - cbOption; 413 414 Assert(cbPad <= 3); 415 if (cbPad) 416 rc = vusbSnifferBlockAddData(pThis, abPad, cbPad); 417 } 426 rc = vusbSnifferBlockAlign(pThis); 418 427 } 419 428 … … 535 544 } 536 545 RTSemFastMutexDestroy(pThis->hMtx); 546 pThis->hMtx = NIL_RTSEMFASTMUTEX; 537 547 } 538 548 VUSBSnifferDestroy(pThis); … … 582 592 DumpFileUsbHeaderLnxMmapped UsbHdr; 583 593 DumpFileUsbSetup UsbSetup; 584 uint64_t u64TimestampEvent = RTTimeNanoTS(); 594 RTTIMESPEC TimeNow; 595 uint64_t u64TimestampEvent; 596 597 RTTimeNow(&TimeNow); 598 u64TimestampEvent = RTTimeSpecGetNano(&TimeNow); 585 599 586 600 /* Start with the enhanced packet block. */ … … 628 642 bool fRecordData = false; 629 643 size_t cbUrbLength = 0; 644 uint32_t cbCapturedLength = sizeof(UsbHdr); 630 645 631 646 if ( pUrb->cbData 632 && ( ( pUrb->enmDir == VUSBDIRECTION_OUT 647 && ( ( ( pUrb->enmDir == VUSBDIRECTION_OUT 648 || pUrb->enmDir == VUSBDIRECTION_SETUP) 633 649 && pUrb->enmType != VUSBXFERTYPE_CTRL 634 650 && pUrb->enmType != VUSBXFERTYPE_MSG 635 651 && enmEvent == VUSBSNIFFEREVENT_SUBMIT) 636 || ( pUrb->enmDir == VUSBDIRECTION_IN 652 || ( ( pUrb->enmDir == VUSBDIRECTION_IN 653 || pUrb->enmDir == VUSBDIRECTION_SETUP) 637 654 && enmEvent == VUSBSNIFFEREVENT_COMPLETE))) 638 655 { 639 Epb.u32CapturedLen = sizeof(UsbHdr) + pUrb->cbData; 640 Epb.u32PacketLen = sizeof(UsbHdr) + pUrb->cbData; 656 cbCapturedLength += pUrb->cbData; 641 657 fRecordData = true; 642 658 } 643 else644 {645 Epb.u32CapturedLen = sizeof(UsbHdr);646 Epb.u32PacketLen = sizeof(UsbHdr);647 }648 659 649 660 if (pUrb->enmType == VUSBXFERTYPE_MSG || pUrb->enmType == VUSBXFERTYPE_CTRL) 650 661 { 651 662 PVUSBSETUP pSetup = (PVUSBSETUP)pUrb->abData; 652 cbUrbLength = pSetup->wLength ;663 cbUrbLength = pSetup->wLength + sizeof(DumpFileUsbSetup); 653 664 } 654 665 else 655 666 cbUrbLength = pUrb->cbData; 667 668 Epb.u32CapturedLen = cbCapturedLength; 669 Epb.u32PacketLen = cbCapturedLength; 656 670 657 671 UsbHdr.u8EndpointNumber = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? 0x80 : 0x00);
Note:
See TracChangeset
for help on using the changeset viewer.