Changeset 37596 in vbox for trunk/src/VBox/Devices/Network/DrvVDE.cpp
- Timestamp:
- Jun 22, 2011 7:30:06 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 72442
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvVDE.cpp
r37299 r37596 34 34 #include <iprt/param.h> 35 35 #include <iprt/path.h> 36 #include <iprt/pipe.h> 36 37 #include <iprt/semaphore.h> 37 38 #include <iprt/string.h> … … 64 65 /** Pointer to the driver instance. */ 65 66 PPDMDRVINS pDrvIns; 66 /** VDE device file handle. */67 RTFILE FileDevice;68 67 /** The configured VDE device name. */ 69 68 char *pszDeviceName; 70 69 /** The write end of the control pipe. */ 71 RT FILEPipeWrite;70 RTPIPE hPipeWrite; 72 71 /** The read end of the control pipe. */ 73 RT FILEPipeRead;72 RTPIPE hPipeRead; 74 73 /** Reader thread. */ 75 74 PPDMTHREAD pThread; 76 75 /** The connection to the VDE switch */ 77 VDECONN * vdeconn;76 VDECONN *pVdeConn; 78 77 79 78 /** @todo The transmit thread. */ … … 225 224 226 225 ssize_t cbSent; 227 cbSent = vde_send(pThis-> vdeconn, pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, 0);226 cbSent = vde_send(pThis->pVdeConn, pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, 0); 228 227 rc = cbSent < 0 ? RTErrConvertFromErrno(-cbSent) : VINF_SUCCESS; 229 228 } … … 241 240 iSeg, cSegs, &cbSegFrame); 242 241 ssize_t cbSent; 243 cbSent = vde_send(pThis-> vdeconn, pvSegFrame, cbSegFrame, 0);242 cbSent = vde_send(pThis->pVdeConn, pvSegFrame, cbSegFrame, 0); 244 243 rc = cbSent < 0 ? RTErrConvertFromErrno(-cbSent) : VINF_SUCCESS; 245 244 if (RT_FAILURE(rc)) … … 319 318 */ 320 319 struct pollfd aFDs[2]; 321 aFDs[0].fd = vde_datafd(pThis-> vdeconn);320 aFDs[0].fd = vde_datafd(pThis->pVdeConn); 322 321 aFDs[0].events = POLLIN | POLLPRI; 323 322 aFDs[0].revents = 0; 324 aFDs[1].fd = pThis->PipeRead;323 aFDs[1].fd = RTPipeToNative(pThis->hPipeRead); 325 324 aFDs[1].events = POLLIN | POLLPRI | POLLERR | POLLHUP; 326 325 aFDs[1].revents = 0; … … 343 342 char achBuf[16384]; 344 343 ssize_t cbRead = 0; 345 cbRead = vde_recv(pThis-> vdeconn, achBuf, sizeof(achBuf), 0);344 cbRead = vde_recv(pThis->pVdeConn, achBuf, sizeof(achBuf), 0); 346 345 rc = cbRead < 0 ? RTErrConvertFromErrno(-cbRead) : VINF_SUCCESS; 347 346 if (RT_SUCCESS(rc)) … … 404 403 char ch; 405 404 size_t cbRead; 406 RT FileRead(pThis->PipeRead, &ch, 1, &cbRead);405 RTPipeRead(pThis->hPipeRead, &ch, 1, &cbRead); 407 406 } 408 407 else … … 440 439 PDRVVDE pThis = PDMINS_2_DATA(pDrvIns, PDRVVDE); 441 440 442 int rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL); 441 size_t cbIgnored; 442 int rc = RTPipeWrite(pThis->hPipeWrite, "", 1, &cbIgnored); 443 443 AssertRC(rc); 444 444 … … 481 481 * Terminate the control pipe. 482 482 */ 483 if (pThis->PipeWrite != NIL_RTFILE) 484 { 485 int rc = RTFileClose(pThis->PipeWrite); 486 AssertRC(rc); 487 pThis->PipeWrite = NIL_RTFILE; 488 } 489 if (pThis->PipeRead != NIL_RTFILE) 490 { 491 int rc = RTFileClose(pThis->PipeRead); 492 AssertRC(rc); 493 pThis->PipeRead = NIL_RTFILE; 494 } 483 RTPipeClose(pThis->hPipeWrite); 484 pThis->hPipeWrite = NIL_RTPIPE; 485 RTPipeClose(pThis->hPipeRead); 486 pThis->hPipeRead = NIL_RTPIPE; 495 487 496 488 MMR3HeapFree(pThis->pszDeviceName); … … 502 494 RTCritSectDelete(&pThis->XmitLock); 503 495 504 vde_close(pThis->vdeconn); 496 vde_close(pThis->pVdeConn); 497 pThis->pVdeConn = NULL; 498 505 499 #ifdef VBOX_WITH_STATISTICS 506 500 /* … … 530 524 * Init the static parts. 531 525 */ 532 pThis->pDrvIns = pDrvIns; 533 pThis->FileDevice = NIL_RTFILE; 534 pThis->pszDeviceName = NULL; 535 pThis->PipeRead = NIL_RTFILE; 536 pThis->PipeWrite = NIL_RTFILE; 526 pThis->pDrvIns = pDrvIns; 527 pThis->pszDeviceName = NULL; 528 pThis->hPipeRead = NIL_RTPIPE; 529 pThis->hPipeWrite = NIL_RTPIPE; 537 530 538 531 /* IBase */ 539 pDrvIns->IBase.pfnQueryInterface = drvVDEQueryInterface;532 pDrvIns->IBase.pfnQueryInterface = drvVDEQueryInterface; 540 533 /* INetwork */ 541 534 pThis->INetworkUp.pfnBeginXmit = drvVDENetworkUp_BeginXmit; … … 592 585 return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS, 593 586 N_("VDEplug library: not found")); 594 pThis-> vdeconn = vde_open(szNetwork, "VirtualBOX", NULL);595 if (pThis-> vdeconn == NULL)587 pThis->pVdeConn = vde_open(szNetwork, "VirtualBOX", NULL); 588 if (pThis->pVdeConn == NULL) 596 589 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS, 597 590 N_("Failed to connect to the VDE SWITCH")); … … 606 599 * Create the control pipe. 607 600 */ 608 int fds[2]; 609 if (pipe(&fds[0]) != 0) /** @todo RTPipeCreate() or something... */ 610 { 611 rc = RTErrConvertFromErrno(errno); 612 AssertRC(rc); 613 return rc; 614 } 615 pThis->PipeRead = fds[0]; 616 pThis->PipeWrite = fds[1]; 601 rc = RTPipeCreate(&pThis->hPipeRead, &pThis->hPipeWrite, 0 /*fFlags*/); 602 AssertRCReturn(rc, rc); 617 603 618 604 /*
Note:
See TracChangeset
for help on using the changeset viewer.