Changeset 18014 in vbox
- Timestamp:
- Mar 17, 2009 11:59:31 AM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl2.cpp
r17961 r18014 78 78 # include <Ntddndis.h> 79 79 # include <devguid.h> 80 #endif 81 82 #if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT) 83 # include <HostNetworkInterfaceImpl.h> 84 # include <netif.h> 80 85 #endif 81 86 … … 1801 1806 networkName = Bstr("HostInterfaceNetworking-vboxnet0"); 1802 1807 #endif 1808 #ifndef RT_OS_WINDOWS 1809 Bstr HifName; 1810 hrc = networkAdapter->COMGETTER(HostInterface)(HifName.asOutParam()); 1811 if(FAILED(hrc)) 1812 { 1813 LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostInterface) failed, hrc (0x%x)", hrc)); 1814 H(); 1815 } 1816 1817 Utf8Str HifNameUtf8(HifName); 1818 const char *pszHifName = HifNameUtf8.raw(); 1819 ComPtr<IHostNetworkInterface> hostInterface; 1820 rc = host->FindHostNetworkInterfaceByName(HifName, hostInterface.asOutParam()); 1821 if (!SUCCEEDED(rc)) 1822 { 1823 LogRel(("NetworkAttachmentType_HostOnly: FindByName failed, rc (0x%x)", rc)); 1824 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS, 1825 N_("Inexistent host networking interface, name '%ls'"), 1826 HifName.raw()); 1827 } 1828 Bstr tmpAddr, tmpMask; 1829 hrc = virtualBox->GetExtraData(Bstr("HostOnly/vboxnet0/IPAddress"), tmpAddr.asOutParam()); 1830 if (SUCCEEDED(hrc) && !tmpAddr.isNull()) 1831 { 1832 hrc = virtualBox->GetExtraData(Bstr("HostOnly/vboxnet0/IPNetMask"), tmpMask.asOutParam()); 1833 if (SUCCEEDED(hrc) && !tmpAddr.isEmpty()) 1834 hrc = hostInterface->EnableStaticIpConfig(tmpAddr, tmpMask); 1835 } 1836 else 1837 hrc = hostInterface->EnableStaticIpConfig(Bstr(VBOXNET_IPV4ADDR_DEFAULT), 1838 Bstr(VBOXNET_IPV4MASK_DEFAULT)); 1839 1840 1841 hrc = virtualBox->GetExtraData(Bstr("HostOnly/vboxnet0/IPV6Address"), tmpAddr.asOutParam()); 1842 if (SUCCEEDED(hrc)) 1843 hrc = virtualBox->GetExtraData(Bstr("HostOnly/vboxnet0/IPV6NetMask"), tmpMask.asOutParam()); 1844 if (SUCCEEDED(hrc) && !tmpAddr.isEmpty()) 1845 hrc = hostInterface->EnableStaticIpConfigV6(tmpAddr, Utf8Str(tmpMask).toUInt32()); 1846 #endif 1803 1847 break; 1804 1848 } -
trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp
r18000 r18014 217 217 if (m.IPAddress == 0) 218 218 { 219 Bstr( "").detachTo(aIPAddress);219 Bstr(VBOXNET_IPV4ADDR_DEFAULT).detachTo(aIPAddress); 220 220 return S_OK; 221 221 } … … 250 250 CheckComRCReturnRC (autoCaller.rc()); 251 251 252 if (m. IPAddress == 0 || m.networkMask == 0)253 { 254 Bstr( "").detachTo(aNetworkMask);252 if (m.networkMask == 0) 253 { 254 Bstr(VBOXNET_IPV4MASK_DEFAULT).detachTo(aNetworkMask); 255 255 return S_OK; 256 256 } … … 417 417 { 418 418 if (m.IPAddress) 419 return NetIfEnableStaticIpConfig(mVBox, this, m.IPAddress, 0, 0); 419 { 420 int rc = NetIfEnableStaticIpConfig(mVBox, this, m.IPAddress, 0, 0); 421 if (RT_SUCCESS(rc)) 422 { 423 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw())), Bstr("")))) 424 return E_FAIL; 425 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw())), Bstr("")))) 426 return E_FAIL; 427 return S_OK; 428 } 429 } 420 430 else 421 431 return S_OK; … … 432 442 if(mask != INADDR_NONE) 433 443 { 434 i nt rc = S_OK;435 if (m.IPAddress != ip || m.networkMask != mask)436 444 if (m.IPAddress == ip && m.networkMask == mask) 445 return S_OK; 446 int rc = NetIfEnableStaticIpConfig(mVBox, this, m.IPAddress, ip, mask); 437 447 if (RT_SUCCESS(rc)) 438 448 { 449 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw())), Bstr(aIPAddress)))) 450 return E_FAIL; 451 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw())), Bstr(aNetMask)))) 452 return E_FAIL; 439 453 return S_OK; 440 454 } … … 470 484 aIPV6MaskPrefixLength = 64; 471 485 rc = NetIfEnableStaticIpConfigV6(mVBox, this, m.IPV6Address, aIPV6Address, aIPV6MaskPrefixLength); 472 } 473 if (RT_FAILURE(rc)) 474 { 475 LogRel(("Failed to EnableStaticIpConfigV6 with rc=%Vrc\n", rc)); 476 return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL; 486 if (RT_FAILURE(rc)) 487 { 488 LogRel(("Failed to EnableStaticIpConfigV6 with rc=%Vrc\n", rc)); 489 return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL; 490 } 491 else 492 { 493 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPV6Address", mInterfaceName.raw())), Bstr(aIPV6Address)))) 494 return E_FAIL; 495 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPV6NetMask", mInterfaceName.raw())), 496 Bstr(Utf8StrFmt("%u", aIPV6MaskPrefixLength))))) 497 return E_FAIL; 498 } 499 477 500 } 478 501 return S_OK; -
trunk/src/VBox/Main/include/netif.h
r17982 r18014 27 27 #include <iprt/asm.h> 28 28 29 //#include "VBox/com/ptr.h"30 //#include <list> 29 #define VBOXNET_IPV4ADDR_DEFAULT "192.168.56.1" 30 #define VBOXNET_IPV4MASK_DEFAULT "255.255.255.0" 31 31 32 32 #if 1
Note:
See TracChangeset
for help on using the changeset viewer.