VirtualBox

Changeset 36057 in vbox


Ignore:
Timestamp:
Feb 22, 2011 8:56:44 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70169
Message:

Main/NetIf: Fixed host-only interface creation failure on Windows (#3873)

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/netif.h

    r35785 r36057  
    147147{
    148148    /* 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);
    152154
    153155    in_addr tmp;
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r35964 r36057  
    11011101    int r = NetIfCreateHostOnlyNetworkInterface(m->pParent, aHostNetworkInterface, aProgress);
    11021102    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;
    11231104
    11241105    return r == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL;
  • trunk/src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp

    r35638 r36057  
    557557    unconst(mVBox) = pVBox;
    558558
     559#if !defined(RT_OS_WINDOWS)
    559560    /* If IPv4 address hasn't been initialized */
    560     if (m.IPAddress == 0)
     561    if (m.IPAddress == 0 && mIfType == HostNetworkInterfaceType_HostOnly)
    561562    {
    562563        Bstr tmpAddr, tmpMask;
     
    564565        hrc = mVBox->GetExtraData(BstrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw()).raw(), tmpMask.asOutParam());
    565566        if (tmpAddr.isEmpty())
     567        {
    566568            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
    567582        if (tmpMask.isEmpty())
     583        {
    568584            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        }
    569590        m.IPAddress = inet_addr(Utf8Str(tmpAddr).c_str());
    570591        m.networkMask = inet_addr(Utf8Str(tmpMask).c_str());
     
    584605        }
    585606    }
     607#endif
    586608
    587609    return S_OK;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette