Changeset 59033 in vbox
- Timestamp:
- Dec 7, 2015 5:28:06 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/win/NetIf-win.cpp
r58885 r59033 1484 1484 }; 1485 1485 1486 static int netIfGetUnboundHostOnlyAdapters(INetCfg *pNetCfg, std::list<BoundAdapter> &adapters) 1487 { 1488 INetCfgComponent *pMiniport; 1489 HRESULT hr; 1490 IEnumNetCfgComponent *pEnumComponent; 1491 1492 if ((hr = pNetCfg->EnumComponents(&GUID_DEVCLASS_NET, &pEnumComponent)) != S_OK) 1493 netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to enumerate network adapter components (0x%x)\n", hr)); 1494 else 1495 { 1496 while ((hr = pEnumComponent->Next(1, &pMiniport, NULL)) == S_OK) 1497 { 1498 GUID guid; 1499 ULONG uComponentStatus; 1500 struct BoundAdapter adapter; 1501 memset(&adapter, 0, sizeof(adapter)); 1502 if ((hr = pMiniport->GetDisplayName(&adapter.pName)) != S_OK) 1503 netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to get device display name (0x%x)\n", hr)); 1504 else if ((hr = pMiniport->GetDeviceStatus(&uComponentStatus)) != S_OK) 1505 netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to get device status (0x%x)\n", hr)); 1506 else if (uComponentStatus != 0) 1507 netIfLog(("netIfGetUnboundHostOnlyAdapters: wrong device status (0x%x)\n", uComponentStatus)); 1508 else if ((hr = pMiniport->GetId(&adapter.pHwId)) != S_OK) 1509 netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to get device id (0x%x)\n", hr)); 1510 else if (_wcsnicmp(adapter.pHwId, L"sun_VBoxNetAdp", sizeof(L"sun_VBoxNetAdp")/2)) 1511 netIfLog(("netIfGetUnboundHostOnlyAdapters: not host-only id = %ls, ignored\n", adapter.pHwId)); 1512 else if ((hr = pMiniport->GetInstanceGuid(&guid)) != S_OK) 1513 netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to get instance id (0x%x)\n", hr)); 1514 else 1515 { 1516 adapter.guid = *(Guid(guid).raw()); 1517 netIfLog(("netIfGetUnboundHostOnlyAdapters: guid=%RTuuid, name=%ls id = %ls\n", &adapter.guid, adapter.pName, adapter.pHwId)); 1518 adapters.push_back(adapter); 1519 adapter.pName = adapter.pHwId = NULL; /* do not free, will be done later */ 1520 } 1521 if (adapter.pHwId) 1522 CoTaskMemFree(adapter.pHwId); 1523 if (adapter.pName) 1524 CoTaskMemFree(adapter.pName); 1525 pMiniport->Release(); 1526 } 1527 Assert(hr == S_OK || hr == S_FALSE); 1528 1529 pEnumComponent->Release(); 1530 } 1531 netIfLog(("netIfGetUnboundHostOnlyAdapters: return\n")); 1532 return VINF_SUCCESS; 1533 } 1534 1486 1535 static HRESULT netIfGetBoundAdapters(std::list<BoundAdapter> &boundAdapters) 1487 1536 { … … 1504 1553 } 1505 1554 1506 if ((hr = pNetCfg->FindComponent(L"oracle_VBoxNetLwf", &pFilter)) != S_OK) 1507 netIfLog(("netIfGetBoundAdapters: could not find 'oracle_VBoxNetLwf' component (0x%x)\n", hr)); 1555 if ((hr = pNetCfg->FindComponent(L"oracle_VBoxNetLwf", &pFilter)) != S_OK 1556 /* fall back to NDIS5 miniport lookup */ 1557 && (hr = pNetCfg->FindComponent(L"sun_VBoxNetFlt", &pFilter))) 1558 netIfLog(("netIfGetBoundAdapters: could not find either 'oracle_VBoxNetLwf' or 'sun_VBoxNetFlt' components (0x%x)\n", hr)); 1508 1559 else 1509 1560 { … … 1569 1620 netIfLog(("netIfGetBoundAdapters: %ls: failed to get hardware id (0x%x)\n", 1570 1621 pwszName, hr)); 1622 else if (!_wcsnicmp(pwszHwId, L"sun_VBoxNetAdp", sizeof(L"sun_VBoxNetAdp")/2)) 1623 netIfLog(("netIfGetBoundAdapters: host-only adapter %ls, ignored\n", pwszName)); 1571 1624 else if ((hr = pAdapter->GetInstanceGuid(&guid)) != S_OK) 1572 1625 netIfLog(("netIfGetBoundAdapters: %ls: failed to get instance GUID (0x%x)\n", … … 1605 1658 pFilter->Release(); 1606 1659 } 1660 /* Host-only adapters are not necessarily bound, add them separately. */ 1661 netIfGetUnboundHostOnlyAdapters(pNetCfg, boundAdapters); 1607 1662 VBoxNetCfgWinReleaseINetCfg(pNetCfg, FALSE); 1608 1663 … … 1813 1868 for (it = boundAdapters.begin(); it != boundAdapters.end(); ++it) 1814 1869 { 1815 if (!RTUuidCompareStr( Guid((*it).guid).raw(), pszUuid + 1))1870 if (!RTUuidCompareStr(&(*it).guid, pszUuid + 1)) 1816 1871 { 1817 1872 (*it).pAdapter = pAdapter;
Note:
See TracChangeset
for help on using the changeset viewer.