VirtualBox

Changeset 18826 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 7, 2009 2:55:12 PM (16 years ago)
Author:
vboxsync
Message:

Main: INetworkAdapter separate properties for hostonly & bridged interface names

Location:
trunk/src/VBox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r18774 r18826  
    694694                    {
    695695                        Bstr strBridgeAdp;
    696                         nic->COMGETTER(HostInterface)(strBridgeAdp.asOutParam());
     696                        nic->COMGETTER(BridgedInterface)(strBridgeAdp.asOutParam());
    697697                        if (details == VMINFO_MACHINEREADABLE)
    698698                        {
     
    721721                    {
    722722                        Bstr strHostonlyAdp;
    723                         nic->COMGETTER(HostInterface)(strHostonlyAdp.asOutParam());
     723                        nic->COMGETTER(HostOnlyInterface)(strHostonlyAdp.asOutParam());
    724724                        if (details == VMINFO_MACHINEREADABLE)
    725725                        {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r18780 r18826  
    130130    std::vector <char *> nictracefile (NetworkAdapterCount, 0);
    131131    std::vector <char *> nicspeed (NetworkAdapterCount, 0);
    132     std::vector <char *> hostifdev (NetworkAdapterCount, 0);
     132    std::vector <char *> bridgedifdev (NetworkAdapterCount, 0);
     133    std::vector <char *> hostonlyifdev (NetworkAdapterCount, 0);
    133134    std::vector <const char *> intnet (NetworkAdapterCount, 0);
    134135    std::vector <const char *> natnet (NetworkAdapterCount, 0);
     
    488489            if (a->argc <= i + 1)
    489490                return errorArgument("Missing argument to '%s'", a->argv[i]);
    490             hostifdev[n - 1] = a->argv[i + 1];
     491            bridgedifdev[n - 1] = a->argv[i + 1];
    491492            i++;
    492493        }
     
    499500            if (a->argc <= i + 1)
    500501                return errorArgument("Missing argument to '%s'", a->argv[i]);
    501             hostifdev[n - 1] = a->argv[i + 1];
     502            bridgedifdev[n - 1] = a->argv[i + 1];
    502503            i++;
    503504        }
     
    511512            if (a->argc <= i + 1)
    512513                return errorArgument("Missing argument to '%s'", a->argv[i]);
    513             hostifdev[n - 1] = a->argv[i + 1];
     514            hostonlyifdev[n - 1] = a->argv[i + 1];
    514515            i++;
    515516        }
     
    16431644
    16441645            /* the host interface device? */
    1645             if (hostifdev[n])
     1646            if (hostonlyifdev[n])
    16461647            {
    16471648                /* remove it? */
    1648                 if (!strcmp(hostifdev[n], "none"))
    1649                 {
    1650                     CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(NULL), 1);
     1649                if (!strcmp(hostonlyifdev[n], "none"))
     1650                {
     1651                    CHECK_ERROR_RET(nic, COMSETTER(HostOnlyInterface)(NULL), 1);
    16511652                }
    16521653                else
    16531654                {
    1654                     CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(Bstr(hostifdev[n])), 1);
     1655                    CHECK_ERROR_RET(nic, COMSETTER(HostOnlyInterface)(Bstr(hostonlyifdev[n])), 1);
     1656                }
     1657            }
     1658
     1659            if (bridgedifdev[n])
     1660            {
     1661                /* remove it? */
     1662                if (!strcmp(bridgedifdev[n], "none"))
     1663                {
     1664                    CHECK_ERROR_RET(nic, COMSETTER(BridgedInterface)(NULL), 1);
     1665                }
     1666                else
     1667                {
     1668                    CHECK_ERROR_RET(nic, COMSETTER(BridgedInterface)(Bstr(bridgedifdev[n])), 1);
    16551669                }
    16561670            }
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r18745 r18826  
    18981898                    if (type == KNetworkAttachmentType_Bridged)
    18991899                        attType = attType.arg (tr ("Bridged network, %1",
    1900                             "details report (network)").arg (adapter.GetHostInterface()));
     1900                            "details report (network)").arg (adapter.GetBridgedInterface()));
    19011901                    else if (type == KNetworkAttachmentType_Internal)
    19021902                        attType = attType.arg (tr ("Internal network, '%1'",
     
    19041904                    else if (type == KNetworkAttachmentType_HostOnly)
    19051905                        attType = attType.arg (tr ("Host-only network, '%1'",
    1906                             "details report (network)").arg (adapter.GetHostInterface()));
     1906                            "details report (network)").arg (adapter.GetHostOnlyInterface()));
    19071907                    else
    19081908                        attType = attType.arg (vboxGlobal().toString (type));
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsNetworkDetails.cpp

    r18733 r18826  
    7676    if (!intName.isEmpty())
    7777        setProperty ("INT_Name", QVariant (intName));
    78     QString ifsName (mAdapter.GetHostInterface());
    79     CHostNetworkInterface ifs =
    80         vboxGlobal().virtualBox().GetHost().FindHostNetworkInterfaceByName (ifsName);
    81     if (!ifs.isNull() && ifs.GetInterfaceType() == KHostNetworkInterfaceType_Bridged)
    82         setProperty ("BRG_Name", QVariant (ifsName));
    83     else if (!ifs.isNull() && ifs.GetInterfaceType() == KHostNetworkInterfaceType_HostOnly)
    84         setProperty ("HOI_Name", QVariant (ifsName));
     78    QString bridgedIfName (mAdapter.GetBridgedInterface());
     79    CHostNetworkInterface bridgedIf =
     80        vboxGlobal().virtualBox().GetHost().FindHostNetworkInterfaceByName (bridgedIfName);
     81    if (!bridgedIf.isNull() && bridgedIf.GetInterfaceType() == KHostNetworkInterfaceType_Bridged)
     82        setProperty ("BRG_Name", QVariant (bridgedIfName));
     83
     84    QString hostonlyIfName (mAdapter.GetHostOnlyInterface());
     85    CHostNetworkInterface hostonlyIf =
     86        vboxGlobal().virtualBox().GetHost().FindHostNetworkInterfaceByName (hostonlyIfName);
     87    if (!hostonlyIf.isNull() && hostonlyIf.GetInterfaceType() == KHostNetworkInterfaceType_HostOnly)
     88        setProperty ("HOI_Name", QVariant (hostonlyIfName));
    8589
    8690    /* Load common settings */
     
    96100    {
    97101        case KNetworkAttachmentType_Bridged:
    98             mAdapter.SetHostInterface (name);
     102            mAdapter.SetBridgedInterface (name);
    99103            break;
    100104        case KNetworkAttachmentType_Internal:
     
    102106            break;
    103107        case KNetworkAttachmentType_HostOnly:
    104             mAdapter.SetHostInterface (name);
     108            mAdapter.SetHostOnlyInterface (name);
    105109            break;
    106110        default:
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r18817 r18826  
    20362036                                if (FAILED(rc)) throw rc;
    20372037                                /* Set the interface name to attach to */
    2038                                 pNetworkAdapter->COMSETTER(HostInterface)(name);
     2038                                pNetworkAdapter->COMSETTER(BridgedInterface)(name);
    20392039                                if (FAILED(rc)) throw rc;
    20402040                                break;
     
    20672067                                if (FAILED(rc)) throw rc;
    20682068                                /* Set the interface name to attach to */
    2069                                 pNetworkAdapter->COMSETTER(HostInterface)(name);
     2069                                pNetworkAdapter->COMSETTER(HostOnlyInterface)(name);
    20702070                                if (FAILED(rc)) throw rc;
    20712071                                break;
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r18758 r18826  
    43354335                /* a valid host interface must have been set */
    43364336                Bstr hostif;
    4337                 adapter->COMGETTER(HostInterface)(hostif.asOutParam());
     4337                adapter->COMGETTER(BridgedInterface)(hostif.asOutParam());
    43384338                if (!hostif)
    43394339                {
     
    57355735        /* The name of the TAP interface we are using */
    57365736        Bstr tapDeviceName;
    5737         rc = networkAdapter->COMGETTER(HostInterface)(tapDeviceName.asOutParam());
     5737        rc = networkAdapter->COMGETTER(BridgedInterface)(tapDeviceName.asOutParam());
    57385738        if (FAILED(rc))
    57395739            tapDeviceName.setNull();  /* Is this necessary? */
     
    58565856        Bstr tapDeviceName, tapTerminateApplication;
    58575857        bool isStatic = true;
    5858         rc = networkAdapter->COMGETTER(HostInterface)(tapDeviceName.asOutParam());
     5858        rc = networkAdapter->COMGETTER(BridgedInterface)(tapDeviceName.asOutParam());
    58595859        if (FAILED(rc) || tapDeviceName.isEmpty())
    58605860        {
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r18710 r18826  
    12381238        }
    12391239#ifdef VMWARE_NET_IN_SLOT_11
    1240         /* 
     1240        /*
    12411241         * Dirty hack for PCI slot compatibility with VMWare,
    12421242         * it assigns slot 11 to the first network controller.
     
    14461446
    14471447                    Bstr HifName;
    1448                     hrc = networkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
     1448                    hrc = networkAdapter->COMGETTER(BridgedInterface)(HifName.asOutParam());
    14491449                    if(FAILED(hrc))
    14501450                    {
     
    18081808# else
    18091809                Bstr HifName;
    1810                 hrc = networkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
     1810                hrc = networkAdapter->COMGETTER(HostOnlyInterface)(HifName.asOutParam());
    18111811                if(FAILED(hrc))
    18121812                {
     
    19581958#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
    19591959                Bstr HifName;
    1960                 hrc = networkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
     1960                hrc = networkAdapter->COMGETTER(HostOnlyInterface)(HifName.asOutParam());
    19611961                if(FAILED(hrc))
    19621962                {
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r18591 r18826  
    396396}
    397397
    398 STDMETHODIMP NetworkAdapter::COMGETTER(HostInterface)(BSTR *aHostInterface)
     398STDMETHODIMP NetworkAdapter::COMGETTER(HostOnlyInterface)(BSTR *aHostInterface)
    399399{
    400400    CheckComArgOutPointerValid(aHostInterface);
     
    405405    AutoReadLock alock (this);
    406406
    407     mData->mHostInterface.cloneTo (aHostInterface);
    408 
    409     return S_OK;
    410 }
    411 
    412 STDMETHODIMP NetworkAdapter::COMSETTER(HostInterface)(IN_BSTR aHostInterface)
     407    mData->mHostOnlyInterface.cloneTo (aHostInterface);
     408
     409    return S_OK;
     410}
     411
     412STDMETHODIMP NetworkAdapter::COMSETTER(HostOnlyInterface)(IN_BSTR aHostInterface)
    413413{
    414414    /** @todo Validate input string length. r=dmik: do it in XML schema?*/
     
    427427    AutoWriteLock alock (this);
    428428
    429     if (mData->mHostInterface != aHostInterface)
    430     {
    431         mData.backup();
    432         mData->mHostInterface = aHostInterface;
     429    if (mData->mHostOnlyInterface != aHostInterface)
     430    {
     431        mData.backup();
     432        mData->mHostOnlyInterface = aHostInterface;
     433
     434        /* leave the lock before informing callbacks */
     435        alock.unlock();
     436
     437        mParent->onNetworkAdapterChange (this);
     438    }
     439
     440    return S_OK;
     441}
     442
     443STDMETHODIMP NetworkAdapter::COMGETTER(BridgedInterface)(BSTR *aHostInterface)
     444{
     445    CheckComArgOutPointerValid(aHostInterface);
     446
     447    AutoCaller autoCaller (this);
     448    CheckComRCReturnRC (autoCaller.rc());
     449
     450    AutoReadLock alock (this);
     451
     452    mData->mBridgedInterface.cloneTo (aHostInterface);
     453
     454    return S_OK;
     455}
     456
     457STDMETHODIMP NetworkAdapter::COMSETTER(BridgedInterface)(IN_BSTR aHostInterface)
     458{
     459    /** @todo Validate input string length. r=dmik: do it in XML schema?*/
     460
     461    /* we don't allow null strings for the host interface (because the @name
     462     * attribute of <HostInterface> must be always present but can be empty). */
     463    CheckComArgNotNull (aHostInterface);
     464
     465    AutoCaller autoCaller (this);
     466    CheckComRCReturnRC (autoCaller.rc());
     467
     468    /* the machine needs to be mutable */
     469    Machine::AutoMutableStateDependency adep (mParent);
     470    CheckComRCReturnRC (adep.rc());
     471
     472    AutoWriteLock alock (this);
     473
     474    if (mData->mBridgedInterface != aHostInterface)
     475    {
     476        mData.backup();
     477        mData->mBridgedInterface = aHostInterface;
    433478
    434479        /* leave the lock before informing callbacks */
     
    926971        ComAssertRet (!name.isNull(), E_FAIL);
    927972
    928         rc = COMSETTER(HostInterface) (name);
     973        rc = COMSETTER(BridgedInterface) (name);
    929974        CheckComRCReturnRC (rc);
    930975
     
    952997        ComAssertRet (!name.isNull(), E_FAIL);
    953998
    954         rc = COMSETTER(HostInterface) (name);
     999        rc = COMSETTER(HostOnlyInterface) (name);
    9551000        CheckComRCReturnRC (rc);
    9561001#endif
     
    10441089        {
    10451090            Key attachmentNode = aAdapterNode.createKey ("BridgedInterface");
    1046             Assert (!mData->mHostInterface.isNull());
    1047             attachmentNode.setValue <Bstr> ("name", mData->mHostInterface);
     1091            Assert (!mData->mBridgedInterface.isNull());
     1092            attachmentNode.setValue <Bstr> ("name", mData->mBridgedInterface);
    10481093            break;
    10491094        }
     
    10591104            Key attachmentNode = aAdapterNode.createKey ("HostOnlyInterface");
    10601105#if defined(VBOX_WITH_NETFLT)
    1061             Assert (!mData->mHostInterface.isNull());
    1062             attachmentNode.setValue <Bstr> ("name", mData->mHostInterface);
     1106            Assert (!mData->mHostOnlyInterface.isNull());
     1107            attachmentNode.setValue <Bstr> ("name", mData->mHostOnlyInterface);
    10631108#endif
    10641109            break;
     
    12111256        {
    12121257            /* reset handle and device name */
    1213             mData->mHostInterface = "";
     1258            mData->mBridgedInterface = "";
    12141259            break;
    12151260        }
     
    12231268#if defined(VBOX_WITH_NETFLT)
    12241269            /* reset handle and device name */
    1225             mData->mHostInterface = "";
     1270            mData->mHostOnlyInterface = "";
    12261271#endif
    12271272            break;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r18804 r18826  
    1093310933  <interface
    1093410934     name="INetworkAdapter" extends="$unknown"
    10935      uuid="65607a27-2b73-4d43-b4cc-0ba2c817fbde"
     10935     uuid="50F03B9E-FF02-4e07-9DA8-86FBF884D62E"
    1093610936     wsmap="managed"
    1093710937     >
     
    1098210982    <attribute name="attachmentType" type="NetworkAttachmentType" readonly="yes"/>
    1098310983
    10984     <attribute name="hostInterface" type="wstring">
    10985       <desc>
    10986         Name of the host network interface the VM is attached to.
    10987       </desc>
    10988     </attribute>
    10989 
     10984    <attribute name="bridgedInterface" type="wstring">
     10985      <desc>
     10986        Name of the bridged network interface the VM is attached to.
     10987      </desc>
     10988    </attribute>
     10989   
     10990    <attribute name="hostOnlyInterface" type="wstring">
     10991      <desc>
     10992        Name of the host only network interface the VM is attached to.
     10993      </desc>
     10994    </attribute>
     10995   
    1099010996    <attribute name="internalNetwork" type="wstring">
    1099110997      <desc>
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r17684 r18826  
    4444            , mAttachmentType (NetworkAttachmentType_Null)
    4545            ,  mCableConnected (TRUE), mLineSpeed (0), mTraceEnabled (FALSE)
    46             , mHostInterface ("") /* cannot be null */
     46            , mHostOnlyInterface ("") /* cannot be null */
     47            , mBridgedInterface ("") /* cannot be null */
    4748        {}
    4849
     
    5758                    mLineSpeed == that.mLineSpeed &&
    5859                    mTraceEnabled == that.mTraceEnabled &&
    59                     mHostInterface == that.mHostInterface &&
     60                    mHostOnlyInterface == that.mHostOnlyInterface &&
     61                    mBridgedInterface == that.mBridgedInterface &&
    6062                    mInternalNetwork == that.mInternalNetwork &&
    6163                    mNATNetwork == that.mNATNetwork);
     
    7173        BOOL mTraceEnabled;
    7274        Bstr mTraceFile;
    73         Bstr mHostInterface;
     75        Bstr mHostOnlyInterface;
     76        Bstr mBridgedInterface;
    7477        Bstr mInternalNetwork;
    7578        Bstr mNATNetwork;
     
    109112    STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
    110113    STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
    111     STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
    112     STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
     114    STDMETHOD(COMGETTER(HostOnlyInterface)) (BSTR *aHostInterface);
     115    STDMETHOD(COMSETTER(HostOnlyInterface)) (IN_BSTR aHostInterface);
     116    STDMETHOD(COMGETTER(BridgedInterface)) (BSTR *aHostInterface);
     117    STDMETHOD(COMSETTER(BridgedInterface)) (IN_BSTR aHostInterface);
    113118    STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
    114119    STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
Note: See TracChangeset for help on using the changeset viewer.

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