Changeset 35356 in vbox for trunk/src/VBox
- Timestamp:
- Dec 27, 2010 9:00:23 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/netif.h
r31539 r35356 68 68 RTNETADDRIPV6 IPv6NetMask; 69 69 BOOL bDhcpEnabled; 70 BOOL bIsDefault; 70 71 RTMAC MACAddress; 71 72 NETIFTYPE enmMediumType; -
trunk/src/VBox/Main/win/NetIf-win.cpp
r34546 r35356 62 62 #define VBOX_APP_NAME L"VirtualBox" 63 63 64 static int collectNetIfInfo(Bstr &strName, Guid &guid, PNETIFINFO pInfo) 64 static int getDefaultInterfaceIndex() 65 { 66 PMIB_IPFORWARDTABLE pIpTable; 67 DWORD dwSize = sizeof(MIB_IPFORWARDTABLE) * 20; 68 DWORD dwRC = NO_ERROR; 69 int iIndex = -1; 70 71 pIpTable = (MIB_IPFORWARDTABLE *)RTMemAlloc(dwSize); 72 if (GetIpForwardTable(pIpTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) 73 { 74 RTMemFree(pIpTable); 75 pIpTable = (MIB_IPFORWARDTABLE *)RTMemAlloc(dwSize); 76 if (!pIpTable) 77 return -1; 78 } 79 dwRC = GetIpForwardTable(pIpTable, &dwSize, 0); 80 if (dwRC == NO_ERROR) 81 { 82 for (unsigned int i = 0; i < pIpTable->dwNumEntries; i++) 83 if (pIpTable->table[i].dwForwardDest == 0) 84 { 85 iIndex = pIpTable->table[i].dwForwardIfIndex; 86 break; 87 } 88 } 89 RTMemFree(pIpTable); 90 return iIndex; 91 } 92 93 static int collectNetIfInfo(Bstr &strName, Guid &guid, PNETIFINFO pInfo, int iDefault) 65 94 { 66 95 DWORD dwRc; … … 163 192 pInfo->enmMediumType = NETIF_T_ETHERNET; 164 193 pInfo->enmStatus = pAdapter->OperStatus == IfOperStatusUp ? NETIF_S_UP : NETIF_S_DOWN; 194 pInfo->bIsDefault = (pAdapter->IfIndex == iDefault); 165 195 RTStrFree(pszUuid); 166 196 break; … … 906 936 907 937 static int vboxNetWinAddComponent(std::list<ComObjPtr<HostNetworkInterface> > * pPist, 908 INetCfgComponent * pncc, HostNetworkInterfaceType enmType) 938 INetCfgComponent * pncc, HostNetworkInterfaceType enmType, 939 int iDefaultInterface) 909 940 { 910 941 LPWSTR lpszName; … … 926 957 memset(&Info, 0, sizeof(Info)); 927 958 Info.Uuid = *(Guid(IfGuid).raw()); 928 rc = collectNetIfInfo(name, Guid(IfGuid), &Info );959 rc = collectNetIfInfo(name, Guid(IfGuid), &Info, iDefaultInterface); 929 960 if (RT_FAILURE(rc)) 930 961 { … … 937 968 if (SUCCEEDED(iface->init(name, enmType, &Info))) 938 969 { 939 pPist->push_back(iface); 970 if (Info.bIsDefault) 971 pPist->push_front(iface); 972 else 973 pPist->push_back(iface); 940 974 rc = VINF_SUCCESS; 941 975 } … … 992 1026 if (!_wcsnicmp(pId, L"sun_VBoxNetAdp", sizeof(L"sun_VBoxNetAdp")/2)) 993 1027 { 994 vboxNetWinAddComponent(&list, pMpNcc, HostNetworkInterfaceType_HostOnly );1028 vboxNetWinAddComponent(&list, pMpNcc, HostNetworkInterfaceType_HostOnly, -1); 995 1029 } 996 1030 CoTaskMemFree(pId); … … 1037 1071 pInfo->Uuid = *(guid.raw()); 1038 1072 1039 return collectNetIfInfo(name, guid, pInfo );1073 return collectNetIfInfo(name, guid, pInfo, getDefaultInterfaceIndex()); 1040 1074 } 1041 1075 } … … 1404 1438 IEnumNetCfgBindingInterface *pEnumBi; 1405 1439 INetCfgBindingInterface *pBi; 1440 int iDefault = getDefaultInterfaceIndex(); 1406 1441 1407 1442 /* we are using the INetCfg API for getting the list of miniports */ … … 1459 1494 if (uComponentStatus == 0) 1460 1495 { 1461 vboxNetWinAddComponent(&list, pMpNcc, HostNetworkInterfaceType_Bridged );1496 vboxNetWinAddComponent(&list, pMpNcc, HostNetworkInterfaceType_Bridged, iDefault); 1462 1497 } 1463 1498 }
Note:
See TracChangeset
for help on using the changeset viewer.