Changeset 105023 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jun 25, 2024 7:13:12 PM (5 months ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNATlibslirp.cpp
r105014 r105023 43 43 /** 44 44 * @callback_method_impl{FNPDMTHREADDRV} 45 * 46 * Queues guest process received packet. Triggered by drvNATRecvWakeup. 45 47 */ 46 48 static DECLCALLBACK(int) drvNATRecv(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 47 49 { 48 LogFlow(("Recv... \n"));49 50 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 50 51 … … 110 111 } 111 112 113 /** 114 * @brief Processes incoming packet (to guest). 115 * 116 * @param pThis Pointer to DRVNAT state for current context. 117 * @param pBuf Pointer to packet buffer. 118 * @param cb Size of packet in buffer. 119 * 120 * @thread NAT 121 */ 112 122 static DECLCALLBACK(void) drvNATRecvWorker(PDRVNAT pThis, void *pBuf, int cb) 113 123 { … … 135 145 rc = pThis->pIAboveNet->pfnReceive(pThis->pIAboveNet, pBuf, cb); 136 146 AssertRC(rc); 137 //RTMemFree(pBuf);138 //pBuf = NULL;147 RTMemFree(pBuf); 148 pBuf = NULL; 139 149 } 140 150 else if ( rc != VERR_TIMEOUT … … 148 158 149 159 done_unlocked: 150 // m_free(m);151 160 ASMAtomicDecU32(&pThis->cPkts); 152 161 … … 164 173 * @param pThis Pointer to the NAT instance. 165 174 * @param pSgBuf The S/G buffer to free. 175 * 176 * @thread NAT 166 177 */ 167 178 static void drvNATFreeSgBuf(PDRVNAT pThis, PPDMSCATTERGATHER pSgBuf) … … 175 186 176 187 RTMemFree(pSgBuf->aSegs[0].pvSeg); 177 //RTMemFree(pSgBuf->pvAllocator);188 RTMemFree(pSgBuf->pvAllocator); 178 189 179 190 pSgBuf->pvAllocator = NULL; … … 548 559 if (pThis->pNATState->nsock + 1 >= pThis->pNATState->uPollCap) 549 560 { 550 // LogFlow(("OLD SIZE: %d\n", sizeof(pThis->pNATState->polls)));551 561 int cbNew = pThis->pNATState->uPollCap * 2 * sizeof(struct pollfd); 552 // LogFlow(("NEW SIZE: %d\n", cbNew));553 562 struct pollfd *pvNew = (struct pollfd *)RTMemRealloc(pThis->pNATState->polls, cbNew); 554 563 if(pvNew) … … 564 573 565 574 int idx = pThis->pNATState->nsock; 566 // LogFlow(("**** nsock = %d\n", pThis->pNATState->nsock));567 575 #ifdef RT_OS_WINDOWS 568 576 pThis->pNATState->polls[idx].fd = libslirp_wrap_RTHandleTableLookup(fd); … … 573 581 pThis->pNATState->polls[idx].revents = 0; 574 582 pThis->pNATState->nsock += 1; 575 // LogFlow(("add_poll_cb: fd=%d, return=%d\n", fd, idx));576 583 return idx; 577 584 } … … 579 586 static int get_revents_cb(int idx, void *opaque) 580 587 { 581 // #ifndef RT_OS_WINDOWS582 588 PDRVNAT pThis = (PDRVNAT)opaque; 583 589 struct pollfd* polls = pThis->pNATState->polls; 584 590 return poll_to_slirp(polls[idx].revents); 585 // #else586 // return 0;587 // #endif588 591 } 589 592 … … 680 683 pThis->pNATState->nsock = 0; 681 684 slirp_pollfds_fill(pThis->pNATState->pSlirp, &uTimeout, add_poll_cb /* SlirpAddPollCb */, pThis /* opaque */); 682 LogFlow(("******** nsock = %d\n", pThis->pNATState->nsock));683 684 685 slirpUpdateTimeout(&uTimeout, pThis); 685 // DWORD dwEvent = WSAWaitForMultipleEvents(VBOX_EVENT_COUNT, phEvents, FALSE,686 // uTimeout, /* :fAlertable */ TRUE);687 // AssertCompile(WSA_WAIT_EVENT_0 == 0);688 // if ( (/*dwEvent < WSA_WAIT_EVENT_0 ||*/ dwEvent > WSA_WAIT_EVENT_0 + pThis->pNATState->nsock - 1)689 // && dwEvent != WSA_WAIT_TIMEOUT && dwEvent != WSA_WAIT_IO_COMPLETION)690 // {691 // int error = WSAGetLastError();692 // LogFlow(("NAT: WSAWaitForMultipleEvents returned %d (error %d)\n", dwEvent, error));693 // // RTAssertPanic();694 // }695 696 // LogFlow(("WSAWaitForMultipleEvents = %d\n", dwEvent));697 698 // if(pThis->pNATState->nsock <= 0)699 // {700 // RTThreadSleep(100);701 // continue;702 // }703 686 704 687 int cChangedFDs = WSAPoll(pThis->pNATState->polls, pThis->pNATState->nsock, uTimeout /* timeout */); 705 int error = WSAGetLastError(); 706 707 LogFlow(("changed fds: %d\n", cChangedFDs)); 688 int error = WSAGetLastError(); 689 708 690 if (cChangedFDs < 0) 709 691 { … … 717 699 if (cChangedFDs == 0) 718 700 { 719 LogFlow(("WSA_WAIT_TIMEOUT\n"));720 701 /* only check for slow/fast timers */ 721 702 slirp_pollfds_poll(pThis->pNATState->pSlirp, false /*select error*/, get_revents_cb /* SlirpGetREventsCb */, pThis /* opaque */); … … 1341 1322 vhost.S_un.S_addr = RT_BSWAP_U32(0x0a000202); 1342 1323 1343 // struct in6_addr vprefix_addr6 = { 0 };1344 1345 1324 struct in_addr vdhcp_start; 1346 1325 vdhcp_start.S_un.S_addr = RT_BSWAP_U32(0x0a00020f); … … 1349 1328 vnameserver.S_un.S_addr = RT_BSWAP_U32(0x0a000203); 1350 1329 #endif 1351 // AssertRC(inet_pton(AF_INET6, "fec0::", &vprefix_addr6));1352 1330 1353 1331 SlirpConfig *pSlirpCfg = new SlirpConfig { 0 }; … … 1359 1337 pSlirpCfg->vnetmask = vnetmask; 1360 1338 pSlirpCfg->vhost = vhost; 1361 // #ifndef RT_OS_WINDOWS1362 1339 pSlirpCfg->in6_enabled = true; 1363 // #else 1364 // pSlirpCfg->in6_enabled = false; 1365 // #endif 1366 1367 #ifndef RT_OS_WINDOWS 1340 1368 1341 inet_pton(AF_INET6, "fd00::", &pSlirpCfg->vprefix_addr6); 1369 #else1370 inet_pton(23, "fd00::", &pSlirpCfg->vprefix_addr6);1371 #endif1372 1373 1342 pSlirpCfg->vprefix_len = 64; 1374 1375 #ifndef RT_OS_WINDOWS1376 1343 inet_pton(AF_INET6, "fd00::2", &pSlirpCfg->vhost6); 1377 #else 1378 inet_pton(23, "fd00::2", &pSlirpCfg->vhost6); 1379 #endif 1380 1381 pSlirpCfg->vhostname = "tmp-vbox-dev"; 1344 1345 pSlirpCfg->vhostname = "vbox"; 1382 1346 pSlirpCfg->tftp_server_name = pThis->pszNextServer; 1383 1347 pSlirpCfg->tftp_path = pThis->pszTFTPPrefix; -
trunk/src/VBox/Devices/Network/DrvNATlibslirp.h
r105013 r105023 64 64 # endif 65 65 # define inet_aton(x, y) inet_pton(2, x, y) 66 # define AF_INET6 23 66 67 #endif 67 68
Note:
See TracChangeset
for help on using the changeset viewer.