VirtualBox

Ignore:
Timestamp:
Jul 27, 2009 2:52:56 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
50430
Message:

Network: check for change in network attachment type and allow only legal ones.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r21787 r21817  
    32943294    HRESULT rc;
    32953295    NetworkAttachmentType_T eAttachmentType;
     3296    Bstr eHostInterface;
     3297    Bstr eInternalNetwork;
    32963298
    32973299    rc = aNetworkAdapter->COMGETTER (AttachmentType) (&eAttachmentType);
     3300    ComAssertComRCRetRC (rc);
     3301    rc = aNetworkAdapter->COMGETTER (HostInterface) (eHostInterface.asOutParam());
     3302    ComAssertComRCRetRC (rc);
     3303    rc = aNetworkAdapter->COMGETTER (InternalNetwork) (eInternalNetwork.asOutParam());
    32983304    ComAssertComRCRetRC (rc);
    32993305#endif /* VBOX_DYNAMIC_NET_ATTACH */
     
    33543360#ifdef VBOX_DYNAMIC_NET_ATTACH
    33553361            if (VBOX_SUCCESS (vrc))
    3356                 rc = doNetworkAdapterChange(pszAdapterName, ulInstance, 0, aNetworkAdapter);
     3362            {
     3363                bool changeAdaptor = false;
     3364
     3365                if (!( (eAttachmentType == NetworkAttachmentType_Null) &&
     3366                       (meAttachmentType[ulInstance] == NetworkAttachmentType_Null)))
     3367                    changeAdaptor = true;
     3368
     3369                /* @todo r=pritesh Need to check for mNATNetwork as well here
     3370                 * when NAT is shifted to use IntNet, till then just compare
     3371                 * if the current and next attachment types are not same
     3372                 */
     3373                if (!( (eAttachmentType == NetworkAttachmentType_NAT) &&
     3374                       (meAttachmentType[ulInstance] == NetworkAttachmentType_NAT)))
     3375                    changeAdaptor = true;
     3376
     3377                if (!( (eAttachmentType == NetworkAttachmentType_Bridged) &&
     3378                       (meAttachmentType[ulInstance] == NetworkAttachmentType_Bridged) &&
     3379                       (mHostInterface[ulInstance] == eHostInterface)))
     3380                    changeAdaptor = true;
     3381
     3382                if (!( (eAttachmentType == NetworkAttachmentType_HostOnly) &&
     3383                       (meAttachmentType[ulInstance] == NetworkAttachmentType_HostOnly) &&
     3384                       (mHostInterface[ulInstance] == eHostInterface)))
     3385                    changeAdaptor = true;
     3386
     3387                if (!( (eAttachmentType == NetworkAttachmentType_Internal) &&
     3388                       (meAttachmentType[ulInstance] == NetworkAttachmentType_Internal) &&
     3389                       (mInternalNetwork[ulInstance] == eInternalNetwork)))
     3390                    changeAdaptor = true;
     3391
     3392                if (changeAdaptor)
     3393                    rc = doNetworkAdapterChange(pszAdapterName, ulInstance, 0, aNetworkAdapter);
     3394            }
    33573395#endif /* VBOX_DYNAMIC_NET_ATTACH */
    33583396
     
    76367674 */
    76377675NetworkAttachmentType_T Console::meAttachmentType[] = {};
     7676#ifdef VBOX_DYNAMIC_NET_ATTACH
     7677Bstr Console::mHostInterface[];
     7678Bstr Console::mInternalNetwork[];
     7679Bstr Console::mNATNetwork[];
     7680#endif
    76387681
    76397682/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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