Changeset 36057 in vbox
- Timestamp:
- Feb 22, 2011 8:56:44 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 70169
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/netif.h
r35785 r36057 147 147 { 148 148 /* Get the index from the name */ 149 int iInstance; 150 if (sscanf(Utf8Str(bstrIfName).c_str(), "vboxnet%d", &iInstance) != 1) 151 return Bstr("0.0.0.0"); 149 Utf8Str strTmp = bstrIfName; 150 const char *pszIfName = strTmp.c_str(); 151 int iInstance = 0, iPos = strcspn(pszIfName, "0123456789"); 152 if (pszIfName[iPos]) 153 iInstance = RTStrToUInt32(pszIfName + iPos); 152 154 153 155 in_addr tmp; -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r35964 r36057 1101 1101 int r = NetIfCreateHostOnlyNetworkInterface(m->pParent, aHostNetworkInterface, aProgress); 1102 1102 if (RT_SUCCESS(r)) 1103 { 1104 Bstr name; 1105 1106 HRESULT hrc = (*aHostNetworkInterface)->COMGETTER(Name)(name.asOutParam()); 1107 ComAssertComRCRet(hrc, hrc); 1108 /* 1109 * We need to write the default IP address and mask to extra data now, 1110 * so the interface gets re-created after vboxnetadp.ko reload. 1111 * Note that we avoid calling EnableStaticIpConfig since it would 1112 * change the address on host's interface as well and we want to 1113 * postpone the change until VM actually starts. 1114 */ 1115 hrc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPAddress", name.raw()).raw(), 1116 getDefaultIPv4Address(name).raw()); 1117 ComAssertComRCRet(hrc, hrc); 1118 hrc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPNetMask", name.raw()).raw(), 1119 Bstr(VBOXNET_IPV4MASK_DEFAULT).raw()); 1120 1121 return hrc; 1122 } 1103 return S_OK; 1123 1104 1124 1105 return r == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL; -
trunk/src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp
r35638 r36057 557 557 unconst(mVBox) = pVBox; 558 558 559 #if !defined(RT_OS_WINDOWS) 559 560 /* If IPv4 address hasn't been initialized */ 560 if (m.IPAddress == 0 )561 if (m.IPAddress == 0 && mIfType == HostNetworkInterfaceType_HostOnly) 561 562 { 562 563 Bstr tmpAddr, tmpMask; … … 564 565 hrc = mVBox->GetExtraData(BstrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw()).raw(), tmpMask.asOutParam()); 565 566 if (tmpAddr.isEmpty()) 567 { 566 568 tmpAddr = getDefaultIPv4Address(mInterfaceName); 569 /* 570 * We need to write the default IP address and mask to extra data now, 571 * so the interface gets re-created after vboxnetadp.ko reload. 572 * Note that we avoid calling EnableStaticIpConfig since it would 573 * change the address on host's interface as well and we want to 574 * postpone the change until VM actually starts. 575 */ 576 hrc = mVBox->SetExtraData(BstrFmt("HostOnly/%ls/IPAddress", 577 mInterfaceName.raw()).raw(), 578 tmpAddr.raw()); 579 ComAssertComRCRet(hrc, hrc); 580 } 581 567 582 if (tmpMask.isEmpty()) 583 { 568 584 tmpMask = Bstr(VBOXNET_IPV4MASK_DEFAULT); 585 hrc = mVBox->SetExtraData(BstrFmt("HostOnly/%ls/IPNetMask", 586 mInterfaceName.raw()).raw(), 587 Bstr(VBOXNET_IPV4MASK_DEFAULT).raw()); 588 ComAssertComRCRet(hrc, hrc); 589 } 569 590 m.IPAddress = inet_addr(Utf8Str(tmpAddr).c_str()); 570 591 m.networkMask = inet_addr(Utf8Str(tmpMask).c_str()); … … 584 605 } 585 606 } 607 #endif 586 608 587 609 return S_OK;
Note:
See TracChangeset
for help on using the changeset viewer.