- Timestamp:
- Mar 23, 2009 1:06:37 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/win/NetIfList-win.cpp
r17985 r18136 65 65 66 66 #define VBOX_APP_NAME L"VirtualBox" 67 68 static HRESULT netIfWinIsHostOnly(IWbemClassObject * pAdapterConfig, BOOL * pbIsHostOnly) 69 { 70 VARIANT vtServiceName; 71 BOOL bIsHostOnly = FALSE; 72 VariantInit(&vtServiceName); 73 74 HRESULT hr = pAdapterConfig->Get(L"ServiceName", 0, &vtServiceName, 0, 0); 75 if(SUCCEEDED(hr)) 76 { 77 *pbIsHostOnly = !Bstr(vtServiceName.bstrVal).compare(Bstr("VBoxNetAdp")); 78 79 VariantClear(&vtServiceName); 80 } 81 82 return hr; 83 } 67 84 68 85 static HRESULT netIfWinCreateIWbemServices(IWbemServices ** ppSvc) … … 794 811 if(SUCCEEDED(hr)) 795 812 { 796 in_addr aIp[1]; 797 in_addr aMask[1]; 798 aIp[0].S_un.S_addr = ip; 799 aMask[0].S_un.S_addr = mask; 800 801 BSTR ObjPath; 802 hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath); 813 BOOL bIsHostOnly; 814 hr = netIfWinIsHostOnly(pAdapterConfig, &bIsHostOnly); 803 815 if(SUCCEEDED(hr)) 804 816 { 805 hr = netIfWinEnableStaticV4(pSvc, ObjPath, aIp, aMask, ip != 0 ? 1 : 0); 806 if(SUCCEEDED(hr)) 807 { 817 if(bIsHostOnly) 818 { 819 in_addr aIp[1]; 820 in_addr aMask[1]; 821 aIp[0].S_un.S_addr = ip; 822 aMask[0].S_un.S_addr = mask; 823 824 BSTR ObjPath; 825 hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath); 826 if(SUCCEEDED(hr)) 827 { 828 hr = netIfWinEnableStaticV4(pSvc, ObjPath, aIp, aMask, ip != 0 ? 1 : 0); 829 if(SUCCEEDED(hr)) 830 { 808 831 #if 0 809 in_addr aGw[1];810 aGw[0].S_un.S_addr = gw;811 hr = netIfWinSetGatewaysV4(pSvc, ObjPath, aGw, 1);812 if(SUCCEEDED(hr))832 in_addr aGw[1]; 833 aGw[0].S_un.S_addr = gw; 834 hr = netIfWinSetGatewaysV4(pSvc, ObjPath, aGw, 1); 835 if(SUCCEEDED(hr)) 813 836 #endif 814 { 815 // hr = netIfWinUpdateConfig(pIf); 837 { 838 // hr = netIfWinUpdateConfig(pIf); 839 } 840 } 841 SysFreeString(ObjPath); 816 842 } 817 843 } 818 SysFreeString(ObjPath); 844 else 845 { 846 hr = E_FAIL; 847 } 819 848 } 820 849 } … … 861 890 static int netIfEnableStaticIpConfigV6(const Guid &guid, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength) 862 891 { 892 #if 0 863 893 RTNETADDRIPV6 Mask; 864 894 int rc = prefixLength2IPv6Address(aIPV6MaskPrefixLength, &Mask); … … 869 899 } 870 900 return rc; 901 #else 902 return VERR_NOT_IMPLEMENTED; 903 #endif 871 904 } 872 905 … … 882 915 if(SUCCEEDED(hr)) 883 916 { 884 B STR ObjPath;885 hr = netIfWin AdapterConfigPath(pAdapterConfig, &ObjPath);917 BOOL bIsHostOnly; 918 hr = netIfWinIsHostOnly(pAdapterConfig, &bIsHostOnly); 886 919 if(SUCCEEDED(hr)) 887 920 { 888 hr = netIfWinEnableDHCP(pSvc, ObjPath); 889 if(SUCCEEDED(hr)) 890 { 891 // hr = netIfWinUpdateConfig(pIf); 892 } 893 SysFreeString(ObjPath); 921 if(bIsHostOnly) 922 { 923 BSTR ObjPath; 924 hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath); 925 if(SUCCEEDED(hr)) 926 { 927 hr = netIfWinEnableDHCP(pSvc, ObjPath); 928 if(SUCCEEDED(hr)) 929 { 930 // hr = netIfWinUpdateConfig(pIf); 931 } 932 SysFreeString(ObjPath); 933 } 934 } 935 else 936 { 937 hr = E_FAIL; 938 } 894 939 } 895 940 } … … 911 956 if(SUCCEEDED(hr)) 912 957 { 913 B STR ObjPath;914 hr = netIfWin AdapterConfigPath(pAdapterConfig, &ObjPath);958 BOOL bIsHostOnly; 959 hr = netIfWinIsHostOnly(pAdapterConfig, &bIsHostOnly); 915 960 if(SUCCEEDED(hr)) 916 961 { 917 hr = netIfWinDhcpRediscover(pSvc, ObjPath); 918 if(SUCCEEDED(hr)) 919 { 962 if(bIsHostOnly) 963 { 964 BSTR ObjPath; 965 hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath); 966 if(SUCCEEDED(hr)) 967 { 968 hr = netIfWinDhcpRediscover(pSvc, ObjPath); 969 if(SUCCEEDED(hr)) 970 { 920 971 // hr = netIfWinUpdateConfig(pIf); 921 } 922 SysFreeString(ObjPath); 972 } 973 SysFreeString(ObjPath); 974 } 975 } 976 else 977 { 978 hr = E_FAIL; 979 } 923 980 } 924 981 }
Note:
See TracChangeset
for help on using the changeset viewer.