- Timestamp:
- Apr 7, 2010 11:20:09 PM (15 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp
r28025 r28070 386 386 { 387 387 mbuf_setlen(pCur, pSG->cbTotal); 388 memcpy(mbuf_data(pCur), pSG->aSegs[0].pv, pSG->cbTotal);388 INTNETSgRead(pSG, mbuf_data(pCur)); 389 389 } 390 390 else 391 391 { 392 392 /* Multi buffer copying. */ 393 size_t cbSrc= pSG->cbTotal;394 uint8_t const *pbSrc = (uint8_t const *)pSG->aSegs[0].pv;395 while (cb Src> 0 && pCur)393 size_t cbLeft = pSG->cbTotal; 394 size_t offSrc = 0; 395 while (cbLeft > 0 && pCur) 396 396 { 397 397 size_t cb = mbuf_maxlen(pCur); 398 if (cb Src < cb)399 cb = cb Src;398 if (cb > cbLeft) 399 cb = cbLeft; 400 400 mbuf_setlen(pCur, cb); 401 memcpy(mbuf_data(pCur), pbSrc, cb);401 INTNETSgReadEx(pSG, off, cb, mbuf_data(pCur)); 402 402 403 403 /* advance */ 404 pbSrc += cb;405 cb Src-= cb;404 offSrc += cb; 405 cbLeft -= cb; 406 406 pCur = mbuf_next(pCur); 407 407 } 408 Assert(cbSrc == 0); 408 409 } 409 410 if (!err) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c
r28025 r28070 225 225 unsigned int i; 226 226 227 if (pSG->cbTotal == 0 || pSG->aSegs[0].cb == 0)227 if (pSG->cbTotal == 0) 228 228 return (NULL); 229 229 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r28069 r28070 317 317 /* Copy the segments. */ 318 318 skb_put(pPkt, pSG->cbTotal); 319 memcpy(pPkt->data, pSG->aSegs[0].pv, pSG->aSegs[0].cb); 320 if (pSG->cSegsUsed > 1) 321 { 322 uint8_t *pbDst = (uint8_t *)pPkt->data + pSG->aSegs[0].cb; 323 size_t iSeg = 0; 324 while (++iSeg < pSG->cSegsUsed) 325 { 326 memcpy(pbDst, pSG->aSegs[iSeg].pv, pSG->aSegs[iSeg].cb); 327 pbDst += pSG->aSegs[iSeg].cb; 328 Assert((uintptr_t)pbDst - (uintptr_t)pPkt->data <= pSG->cbTotal); 329 } 330 } 319 INTNETSgRead(pSG, pPkt->data); 331 320 332 321 /* Set protocol and packet_type fields. */ -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFlt-win.c
r28025 r28070 159 159 { 160 160 DBGPRINT(("device not idle")); 161 Assert (0);161 AssertFailed(); 162 162 // break; 163 163 } … … 181 181 182 182 /* frees memory allocated with vboxNetFltWinMemAlloc */ 183 DECLHIDDEN(void) vboxNetFltWinMemFree(PVOID p MemBuf)184 { 185 NdisFreeMemory(p MemBuf, 0, 0);183 DECLHIDDEN(void) vboxNetFltWinMemFree(PVOID pvMemBuf) 184 { 185 NdisFreeMemory(pvMemBuf, 0, 0); 186 186 } 187 187 … … 264 264 else 265 265 { 266 Assert (0);266 AssertFailed(); 267 267 } 268 268 … … 290 290 if(pDst->MaximumLength < pSrc->Length) 291 291 { 292 Assert (0);292 AssertFailed(); 293 293 Status = NDIS_STATUS_RESOURCES; 294 294 } … … 528 528 * indicates NDIS_STATUS_RESOURCES, we should never have this when processing 529 529 * the "from-host" packets */ 530 Assert (0);530 AssertFailed(); 531 531 LogFlow(("status is not pending, freeing myPacket (%p)\n", pMyPacket)); 532 532 vboxNetFltWinFreeSGNdisPacket(pMyPacket, false); … … 545 545 { 546 546 /*we failed to create our packet */ 547 Assert (0);547 AssertFailed(); 548 548 fStatus = NDIS_STATUS_FAILURE; 549 549 } … … 1214 1214 if(fStatus != NDIS_STATUS_SUCCESS) 1215 1215 { 1216 Assert (0);1216 AssertFailed(); 1217 1217 break; 1218 1218 } … … 1222 1222 if(!pInfo) 1223 1223 { 1224 Assert (0);1224 AssertFailed(); 1225 1225 /* TODO: what status to set? */ 1226 1226 fStatus = NDIS_STATUS_FAILURE; … … 1238 1238 if(fStatus != NDIS_STATUS_SUCCESS) 1239 1239 { 1240 Assert (0);1240 AssertFailed(); 1241 1241 vboxNetFltWinPpFreePacketInfo(pInfo); 1242 1242 vboxNetFltWinMemFree(pSG); … … 1252 1252 if(!pInfo) 1253 1253 { 1254 Assert (0);1254 AssertFailed(); 1255 1255 /* TODO: what status to set? */ 1256 1256 fStatus = NDIS_STATUS_FAILURE; … … 1434 1434 { 1435 1435 /* TODO */ 1436 Assert (0);1436 AssertFailed(); 1437 1437 } 1438 1438 … … 1459 1459 { 1460 1460 LogRel(("OID_GEN_PHYSICAL_MEDIUM failed: Status (0x%x)", Status)); 1461 Assert (0);1461 AssertFailed(); 1462 1462 } 1463 1463 } … … 1482 1482 { 1483 1483 /* TODO */ 1484 Assert (0);1484 AssertFailed(); 1485 1485 return false; 1486 1486 } … … 1506 1506 { 1507 1507 /* TODO: */ 1508 Assert (0);1508 AssertFailed(); 1509 1509 return fStatus; 1510 1510 } … … 1539 1539 { 1540 1540 /* TODO */ 1541 Assert (0);1541 AssertFailed(); 1542 1542 return fStatus; 1543 1543 } … … 1661 1661 PNDIS_PACKET pPacket; 1662 1662 1663 Assert(pSG->cSegsUsed == 1);1664 Assert(pSG->cbTotal == pSG->aSegs[0].cb);1665 1663 Assert(pSG->aSegs[0].pv); 1666 1664 Assert(pSG->cbTotal >= sizeof(ETH_HEADER_SIZE)); 1665 1666 /** @todo Hrmpf, how can we fix this assumption? I fear this'll cause data 1667 * corruption and maybe even BSODs ... */ 1668 AssertReturn(pSG->cSegsUsed == 1 || bCopyMemory, NULL); 1667 1669 1668 1670 #ifdef VBOX_NETFLT_ONDEMAND_BIND … … 1676 1678 { 1677 1679 PNDIS_BUFFER pBuffer; 1678 PVOID p MemBuf;1680 PVOID pvMemBuf; 1679 1681 1680 1682 /* @todo: generally we do not always need to zero-initialize the complete OOB data here, reinitialize only when/what we need, … … 1685 1687 if(bCopyMemory) 1686 1688 { 1687 fStatus = vboxNetFltWinMemAlloc(&p MemBuf, pSG->cbTotal);1689 fStatus = vboxNetFltWinMemAlloc(&pvMemBuf, pSG->cbTotal); 1688 1690 if(fStatus == NDIS_STATUS_SUCCESS) 1689 1691 { 1690 NdisMoveMemory(pMemBuf, pSG->aSegs[0].pv, pSG->cbTotal);1692 INTNETSgRead(pSG, pvMemBuf); 1691 1693 } 1692 1694 else 1693 1695 { 1694 Assert (0);1696 AssertFailed(); 1695 1697 NdisFreePacket(pPacket); 1696 1698 pPacket = NULL; … … 1699 1701 else 1700 1702 { 1701 p MemBuf = pSG->aSegs[0].pv;1703 pvMemBuf = pSG->aSegs[0].pv; 1702 1704 } 1703 1705 if(fStatus == NDIS_STATUS_SUCCESS) … … 1706 1708 NdisAllocateBuffer(&fStatus, &pBuffer, 1707 1709 pAdapt->hSendBufferPoolHandle, 1708 p MemBuf,1710 pvMemBuf, 1709 1711 pSG->cbTotal); 1710 1712 #elif defined(VBOXNETADP) 1711 1713 NdisAllocateBuffer(&fStatus, &pBuffer, 1712 1714 pAdapt->hRecvBufferPoolHandle, 1713 p MemBuf,1715 pvMemBuf, 1714 1716 pSG->cbTotal); 1715 1717 #else 1716 1718 NdisAllocateBuffer(&fStatus, &pBuffer, 1717 1719 bToWire ? pAdapt->hSendBufferPoolHandle : pAdapt->hRecvBufferPoolHandle, 1718 p MemBuf,1720 pvMemBuf, 1719 1721 pSG->cbTotal); 1720 1722 #endif … … 1758 1760 else 1759 1761 { 1760 Assert (0);1762 AssertFailed(); 1761 1763 if(bCopyMemory) 1762 1764 { 1763 vboxNetFltWinMemFree(p MemBuf);1765 vboxNetFltWinMemFree(pvMemBuf); 1764 1766 } 1765 1767 NdisFreePacket(pPacket); … … 1769 1771 else 1770 1772 { 1771 Assert (0);1773 AssertFailed(); 1772 1774 NdisFreePacket(pPacket); 1773 1775 pPacket = NULL; … … 1803 1805 if(pBuffer != NULL) 1804 1806 { 1805 PVOID p MemBuf;1807 PVOID pvMemBuf; 1806 1808 UINT cbLength; 1807 1809 1808 NdisQueryBufferSafe(pBuffer, &p MemBuf, &cbLength, NormalPagePriority);1810 NdisQueryBufferSafe(pBuffer, &pvMemBuf, &cbLength, NormalPagePriority); 1809 1811 NdisFreeBuffer(pBuffer); 1810 1812 if(bFreeMem) 1811 1813 { 1812 vboxNetFltWinMemFree(p MemBuf);1814 vboxNetFltWinMemFree(pvMemBuf); 1813 1815 } 1814 1816 } … … 1881 1883 { 1882 1884 /* TODO: we can not prevent driver unload here */ 1883 Assert (0);1885 AssertFailed(); 1884 1886 1885 1887 Log(("vboxNetFltWinTryFiniIdc - failed, busy.\n")); … … 2150 2152 if(RT_FAILURE(rc)) 2151 2153 { 2152 Assert (0);2154 AssertFailed(); 2153 2155 Status = Context.Status != NDIS_STATUS_SUCCESS ? Context.Status : NDIS_STATUS_FAILURE; 2154 2156 break; … … 2167 2169 if(RT_FAILURE(rc)) 2168 2170 { 2169 Assert (0);2171 AssertFailed(); 2170 2172 Status = Context.Status != NDIS_STATUS_SUCCESS ? Context.Status : NDIS_STATUS_FAILURE; 2171 2173 /* release netflt */ … … 2233 2235 if(Status != NDIS_STATUS_SUCCESS) 2234 2236 { 2235 Assert (0);2237 AssertFailed(); 2236 2238 /* TODO: should we break ? */ 2237 2239 /* break; */ … … 2355 2357 if(Status != NDIS_STATUS_SUCCESS) 2356 2358 { 2357 Assert (0);2359 AssertFailed(); 2358 2360 pAdapt->DeviceName.Buffer = NULL; 2359 2361 break; … … 2364 2366 if(Status != NDIS_STATUS_SUCCESS) 2365 2367 { 2366 Assert (0);2368 AssertFailed(); 2367 2369 break; 2368 2370 } … … 2408 2410 if(RT_FAILURE(rc)) 2409 2411 { 2410 Assert (0);2412 AssertFailed(); 2411 2413 Status = NDIS_STATUS_FAILURE; 2412 2414 break; … … 2654 2656 if(uTotalPacketLength1 != uTotalPacketLength2) 2655 2657 { 2656 Assert (0);2658 AssertFailed(); 2657 2659 bMatch = false; 2658 2660 } … … 2707 2709 { 2708 2710 bMatch = false; 2709 Assert (0);2711 AssertFailed(); 2710 2712 break; 2711 2713 } … … 2754 2756 if(uTotalPacketLength1 != uTotalPacketLength2) 2755 2757 { 2756 Assert (0);2758 AssertFailed(); 2757 2759 bMatch = false; 2758 2760 } … … 2796 2798 { 2797 2799 bMatch = false; 2798 Assert (0);2800 AssertFailed(); 2799 2801 break; 2800 2802 } … … 2907 2909 { 2908 2910 #ifdef VBOX_NETFLT_ONDEMAND_BIND 2909 Assert (0);2911 AssertFailed(); 2910 2912 #endif 2911 2913 rc = VINF_ALREADY_INITIALIZED; … … 2987 2989 if(RT_FAILURE(rc)) 2988 2990 { 2989 Assert (0);2991 AssertFailed(); 2990 2992 break; 2991 2993 } … … 3000 3002 if (RT_FAILURE(rc)) 3001 3003 { 3002 Assert (0);3004 AssertFailed(); 3003 3005 vboxNetFltWinFiniNetFltBase(); 3004 3006 break; … … 3038 3040 if(Status != NDIS_STATUS_SUCCESS) 3039 3041 { 3040 Assert (0);3042 AssertFailed(); 3041 3043 /* pDetachInfo->Status = VERR_GENERAL_FAILURE; */ 3042 3044 } … … 3119 3121 if(Status != NDIS_STATUS_SUCCESS) 3120 3122 { 3121 Assert (0);3123 AssertFailed(); 3122 3124 /* pDetachInfo->Status = VERR_GENERAL_FAILURE; */ 3123 3125 } … … 3418 3420 else 3419 3421 { 3420 Assert (0);3422 AssertFailed(); 3421 3423 rc = VERR_NO_MEMORY; 3422 3424 } … … 3442 3444 else 3443 3445 { 3444 Assert (0);3446 AssertFailed(); 3445 3447 #ifdef VBOXNETADP 3446 3448 STATISTIC_INCREASE(pAdapt->cRxError); … … 3572 3574 { 3573 3575 DBGPRINT(("vboxNetFltWinSetPromiscuous failed, Status (0x%x), fActive (%d)\n", Status, fActive)); 3574 Assert (0);3576 AssertFailed(); 3575 3577 LogRel(("vboxNetFltWinSetPromiscuous failed, Status (0x%x), fActive (%d)\n", Status, fActive)); 3576 3578 }
Note:
See TracChangeset
for help on using the changeset viewer.