VirtualBox

Changeset 61170 in vbox for trunk


Ignore:
Timestamp:
May 24, 2016 4:44:44 PM (9 years ago)
Author:
vboxsync
Message:

8238 VBoxSVC settings - NetworkAdapterImpl

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

Legend:

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

    r61009 r61170  
    77
    88/*
    9  * Copyright (C) 2006-2015 Oracle Corporation
     9 * Copyright (C) 2006-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r57694 r61170  
    77
    88/*
    9  * Copyright (C) 2006-2015 Oracle Corporation
     9 * Copyright (C) 2006-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    114114    HRESULT i_switchToNatNetworking(const com::Utf8Str &aNatNetworkName);
    115115
    116     typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
    117 
    118     struct Data
    119     {
    120         Data() : mSlot(0),
    121                  mEnabled(FALSE),
    122                  mAttachmentType(NetworkAttachmentType_Null),
    123                  mCableConnected(TRUE),
    124                  mLineSpeed(0),
    125                  mPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),
    126                  mTraceEnabled(FALSE),
    127                  mBridgedInterface("") /* cannot be null */,
    128                  mHostOnlyInterface("") /* cannot be null */,
    129                  mNATNetwork("") /* cannot be null */,
    130                  mBootPriority(0)
    131         {}
    132 
    133         NetworkAdapterType_T mAdapterType;
    134         ULONG mSlot;
    135         BOOL mEnabled;
    136         com::Utf8Str mMACAddress;
    137         NetworkAttachmentType_T mAttachmentType;
    138         BOOL mCableConnected;
    139         ULONG mLineSpeed;
    140         NetworkAdapterPromiscModePolicy_T mPromiscModePolicy;
    141         BOOL mTraceEnabled;
    142         com::Utf8Str mTraceFile;
    143         com::Utf8Str mBridgedInterface;
    144         com::Utf8Str mHostOnlyInterface;
    145         com::Utf8Str mInternalNetwork;
    146         com::Utf8Str mNATNetwork;
    147         com::Utf8Str mGenericDriver;
    148         StringsMap mGenericProperties;
    149         ULONG mBootPriority;
    150         com::Utf8Str mBandwidthGroup;
    151     };
    152116
    153117    Machine * const     mParent;
     
    155119    const ComObjPtr<NATEngine> mNATEngine;
    156120
    157     Backupable<Data>    mData;
     121    Backupable<settings::NetworkAdapter> mData;
    158122};
    159123
  • trunk/src/VBox/Main/src-server/NATEngineImpl.cpp

    r61030 r61170  
    2929#include <VBox/com/array.h>
    3030
    31 struct NATEngineData
    32 {
    33     NATEngineData()
    34     {}
    35 
    36     settings::NAT s;
    37 };
    38 
    3931struct NATEngine::Data
    4032{
    41     Backupable<NATEngineData> m;
     33    Backupable<settings::NAT> m;
    4234};
    4335
     
    6860    mData = new Data();
    6961    mData->m.allocate();
    70     mData->m->s.strNetwork.setNull();
    71     mData->m->s.strBindIP.setNull();
     62    mData->m->strNetwork.setNull();
     63    mData->m->strBindIP.setNull();
    7264    unconst(mParent) = aParent;
    7365    unconst(mAdapter) = aAdapter;
     
    192184    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    193185    if (aMtu)
    194         *aMtu = mData->m->s.u32Mtu;
     186        *aMtu = mData->m->u32Mtu;
    195187    if (aSockSnd)
    196         *aSockSnd = mData->m->s.u32SockSnd;
     188        *aSockSnd = mData->m->u32SockSnd;
    197189    if (aSockRcv)
    198         *aSockRcv = mData->m->s.u32SockRcv;
     190        *aSockRcv = mData->m->u32SockRcv;
    199191    if (aTcpWndSnd)
    200         *aTcpWndSnd = mData->m->s.u32TcpSnd;
     192        *aTcpWndSnd = mData->m->u32TcpSnd;
    201193    if (aTcpWndRcv)
    202         *aTcpWndRcv = mData->m->s.u32TcpRcv;
     194        *aTcpWndRcv = mData->m->u32TcpRcv;
    203195
    204196    return S_OK;
     
    215207    }
    216208    if (aMtu)
    217         mData->m->s.u32Mtu = aMtu;
     209        mData->m->u32Mtu = aMtu;
    218210    if (aSockSnd)
    219         mData->m->s.u32SockSnd = aSockSnd;
     211        mData->m->u32SockSnd = aSockSnd;
    220212    if (aSockRcv)
    221         mData->m->s.u32SockRcv = aSockSnd;
     213        mData->m->u32SockRcv = aSockSnd;
    222214    if (aTcpWndSnd)
    223         mData->m->s.u32TcpSnd = aTcpWndSnd;
     215        mData->m->u32TcpSnd = aTcpWndSnd;
    224216    if (aTcpWndRcv)
    225         mData->m->s.u32TcpRcv = aTcpWndRcv;
     217        mData->m->u32TcpRcv = aTcpWndRcv;
    226218
    227219    return S_OK;
     
    233225    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    234226
    235     aRedirects.resize(mData->m->s.mapRules.size());
     227    aRedirects.resize(mData->m->mapRules.size());
    236228    size_t i = 0;
    237229    settings::NATRulesMap::const_iterator it;
    238     for (it = mData->m->s.mapRules.begin(); it != mData->m->s.mapRules.end(); ++it, ++i)
     230    for (it = mData->m->mapRules.begin(); it != mData->m->mapRules.end(); ++it, ++i)
    239231    {
    240232        settings::NATRule r = it->second;
     
    272264
    273265    settings::NATRulesMap::iterator it;
    274     for (it = mData->m->s.mapRules.begin(); it != mData->m->s.mapRules.end(); ++it)
     266    for (it = mData->m->mapRules.begin(); it != mData->m->mapRules.end(); ++it)
    275267    {
    276268        r = it->second;
     
    292284    r.strGuestIP = aGuestIP;
    293285    r.u16GuestPort = aGuestPort;
    294     mData->m->s.mapRules.insert(std::make_pair(name, r));
     286    mData->m->mapRules.insert(std::make_pair(name, r));
    295287    mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    296288
     
    307299{
    308300    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    309     settings::NATRulesMap::iterator it = mData->m->s.mapRules.find(aName);
    310     if (it == mData->m->s.mapRules.end())
     301    settings::NATRulesMap::iterator it = mData->m->mapRules.find(aName);
     302    if (it == mData->m->mapRules.end())
    311303        return E_INVALIDARG;
    312304    mData->m.backup();
     
    317309     */
    318310    settings::NATRule r = it->second;
    319     Utf8Str strHostIP = r.strHostIP;
    320     Utf8Str strGuestIP = r.strGuestIP;
    321     NATProtocol_T proto = r.proto;
    322     uint16_t u16HostPort = r.u16HostPort;
    323     uint16_t u16GuestPort = r.u16GuestPort;
    324311    ULONG ulSlot;
    325312    mAdapter->COMGETTER(Slot)(&ulSlot);
    326313
    327     mData->m->s.mapRules.erase(aName); /* NB: erase by key, "it" may not be valid */
     314    mData->m->mapRules.erase(aName); /* NB: erase by key, "it" may not be valid */
    328315    mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    329316    alock.release();
    330     mParent->i_onNATRedirectRuleChange(ulSlot, TRUE, Bstr(aName).raw(), proto, Bstr(strHostIP).raw(),
    331                                        u16HostPort, Bstr(strGuestIP).raw(), u16GuestPort);
     317    mParent->i_onNATRedirectRuleChange(ulSlot, TRUE, Bstr(aName).raw(), r.proto, Bstr(r.strHostIP).raw(),
     318                                       r.u16HostPort, Bstr(r.strGuestIP).raw(), r.u16GuestPort);
    332319    return S_OK;
    333320}
     
    339326
    340327    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    341     mData->m->s = data;
     328    mData->m.assignCopy(&data);
    342329    return S_OK;
    343330}
     
    351338    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    352339    HRESULT rc = S_OK;
    353     data = mData->m->s;
     340    data = *mData->m.data();
    354341    return rc;
    355342}
     
    358345{
    359346    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    360     if (mData->m->s.strNetwork != aNetwork)
    361     {
    362         mData->m.backup();
    363         mData->m->s.strNetwork = aNetwork;
     347    if (mData->m->strNetwork != aNetwork)
     348    {
     349        mData->m.backup();
     350        mData->m->strNetwork = aNetwork;
    364351        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    365352    }
     
    371358{
    372359    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    373     if (!mData->m->s.strNetwork.isEmpty())
    374     {
    375         aNetwork = mData->m->s.strNetwork;
    376         Log(("Getter (this:%p) Network: %s\n", this, mData->m->s.strNetwork.c_str()));
     360    if (!mData->m->strNetwork.isEmpty())
     361    {
     362        aNetwork = mData->m->strNetwork;
     363        Log(("Getter (this:%p) Network: %s\n", this, mData->m->strNetwork.c_str()));
    377364    }
    378365    return S_OK;
     
    382369{
    383370    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    384     if (mData->m->s.strBindIP != aHostIP)
    385     {
    386         mData->m.backup();
    387         mData->m->s.strBindIP = aHostIP;
     371    if (mData->m->strBindIP != aHostIP)
     372    {
     373        mData->m.backup();
     374        mData->m->strBindIP = aHostIP;
    388375        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    389376    }
     
    395382    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    396383
    397     if (!mData->m->s.strBindIP.isEmpty())
    398         aBindIP = mData->m->s.strBindIP;
     384    if (!mData->m->strBindIP.isEmpty())
     385        aBindIP = mData->m->strBindIP;
    399386    return S_OK;
    400387}
     
    403390{
    404391    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    405     if (mData->m->s.strTFTPPrefix != aTFTPPrefix)
    406     {
    407         mData->m.backup();
    408         mData->m->s.strTFTPPrefix = aTFTPPrefix;
     392    if (mData->m->strTFTPPrefix != aTFTPPrefix)
     393    {
     394        mData->m.backup();
     395        mData->m->strTFTPPrefix = aTFTPPrefix;
    409396        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    410397    }
     
    417404    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    418405
    419     if (!mData->m->s.strTFTPPrefix.isEmpty())
    420     {
    421         aTFTPPrefix = mData->m->s.strTFTPPrefix;
    422         Log(("Getter (this:%p) TFTPPrefix: %s\n", this, mData->m->s.strTFTPPrefix.c_str()));
     406    if (!mData->m->strTFTPPrefix.isEmpty())
     407    {
     408        aTFTPPrefix = mData->m->strTFTPPrefix;
     409        Log(("Getter (this:%p) TFTPPrefix: %s\n", this, mData->m->strTFTPPrefix.c_str()));
    423410    }
    424411    return S_OK;
     
    428415{
    429416    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    430     if (mData->m->s.strTFTPBootFile != aTFTPBootFile)
    431     {
    432         mData->m.backup();
    433         mData->m->s.strTFTPBootFile = aTFTPBootFile;
     417    if (mData->m->strTFTPBootFile != aTFTPBootFile)
     418    {
     419        mData->m.backup();
     420        mData->m->strTFTPBootFile = aTFTPBootFile;
    434421        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    435422    }
     
    441428{
    442429    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    443     if (!mData->m->s.strTFTPBootFile.isEmpty())
    444     {
    445         aTFTPBootFile = mData->m->s.strTFTPBootFile;
    446         Log(("Getter (this:%p) BootFile: %s\n", this, mData->m->s.strTFTPBootFile.c_str()));
     430    if (!mData->m->strTFTPBootFile.isEmpty())
     431    {
     432        aTFTPBootFile = mData->m->strTFTPBootFile;
     433        Log(("Getter (this:%p) BootFile: %s\n", this, mData->m->strTFTPBootFile.c_str()));
    447434    }
    448435    return S_OK;
     
    453440{
    454441    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    455     if (mData->m->s.strTFTPNextServer != aTFTPNextServer)
    456     {
    457         mData->m.backup();
    458         mData->m->s.strTFTPNextServer = aTFTPNextServer;
     442    if (mData->m->strTFTPNextServer != aTFTPNextServer)
     443    {
     444        mData->m.backup();
     445        mData->m->strTFTPNextServer = aTFTPNextServer;
    459446        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    460447    }
     
    465452{
    466453    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    467     if (!mData->m->s.strTFTPNextServer.isEmpty())
    468     {
    469         aTFTPNextServer =  mData->m->s.strTFTPNextServer;
    470         Log(("Getter (this:%p) NextServer: %s\n", this, mData->m->s.strTFTPNextServer.c_str()));
     454    if (!mData->m->strTFTPNextServer.isEmpty())
     455    {
     456        aTFTPNextServer =  mData->m->strTFTPNextServer;
     457        Log(("Getter (this:%p) NextServer: %s\n", this, mData->m->strTFTPNextServer.c_str()));
    471458    }
    472459    return S_OK;
     
    478465    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    479466
    480     if (mData->m->s.fDNSPassDomain != RT_BOOL(aDNSPassDomain))
    481     {
    482         mData->m.backup();
    483         mData->m->s.fDNSPassDomain = RT_BOOL(aDNSPassDomain);
     467    if (mData->m->fDNSPassDomain != RT_BOOL(aDNSPassDomain))
     468    {
     469        mData->m.backup();
     470        mData->m->fDNSPassDomain = RT_BOOL(aDNSPassDomain);
    484471        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    485472    }
     
    490477{
    491478    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    492     *aDNSPassDomain = mData->m->s.fDNSPassDomain;
     479    *aDNSPassDomain = mData->m->fDNSPassDomain;
    493480    return S_OK;
    494481}
     
    499486    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    500487
    501     if (mData->m->s.fDNSProxy != RT_BOOL(aDNSProxy))
    502     {
    503         mData->m.backup();
    504         mData->m->s.fDNSProxy = RT_BOOL(aDNSProxy);
     488    if (mData->m->fDNSProxy != RT_BOOL(aDNSProxy))
     489    {
     490        mData->m.backup();
     491        mData->m->fDNSProxy = RT_BOOL(aDNSProxy);
    505492        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    506493    }
     
    511498{
    512499    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    513     *aDNSProxy = mData->m->s.fDNSProxy;
     500    *aDNSProxy = mData->m->fDNSProxy;
    514501    return S_OK;
    515502}
     
    519506{
    520507    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    521     *aDNSUseHostResolver = mData->m->s.fDNSUseHostResolver;
     508    *aDNSUseHostResolver = mData->m->fDNSUseHostResolver;
    522509    return S_OK;
    523510}
     
    526513HRESULT NATEngine::setDNSUseHostResolver(BOOL aDNSUseHostResolver)
    527514{
    528     if (mData->m->s.fDNSUseHostResolver != RT_BOOL(aDNSUseHostResolver))
    529     {
    530         mData->m.backup();
    531         mData->m->s.fDNSUseHostResolver = RT_BOOL(aDNSUseHostResolver);
     515    if (mData->m->fDNSUseHostResolver != RT_BOOL(aDNSUseHostResolver))
     516    {
     517        mData->m.backup();
     518        mData->m->fDNSUseHostResolver = RT_BOOL(aDNSUseHostResolver);
    532519        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    533520    }
     
    538525{
    539526    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    540     ULONG uAliasMode = (mData->m->s.fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);
    541     uAliasMode |= (mData->m->s.fAliasLog ? NATAliasMode_AliasLog : 0);
    542     uAliasMode |= (mData->m->s.fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);
     527    ULONG uAliasMode = (mData->m->fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);
     528    uAliasMode |= (mData->m->fAliasLog ? NATAliasMode_AliasLog : 0);
     529    uAliasMode |= (mData->m->fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);
    543530    if (uAliasMode != aAliasMode)
    544531    {
    545532        mData->m.backup();
    546         mData->m->s.fAliasUseSamePorts = RT_BOOL(aAliasMode & NATAliasMode_AliasUseSamePorts);
    547         mData->m->s.fAliasLog = RT_BOOL(aAliasMode & NATAliasMode_AliasLog);
    548         mData->m->s.fAliasProxyOnly = RT_BOOL(aAliasMode & NATAliasMode_AliasProxyOnly);
     533        mData->m->fAliasUseSamePorts = RT_BOOL(aAliasMode & NATAliasMode_AliasUseSamePorts);
     534        mData->m->fAliasLog = RT_BOOL(aAliasMode & NATAliasMode_AliasLog);
     535        mData->m->fAliasProxyOnly = RT_BOOL(aAliasMode & NATAliasMode_AliasProxyOnly);
    549536        mParent->i_setModified(Machine::IsModified_NetworkAdapters);
    550537    }
     
    555542{
    556543    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    557     ULONG uAliasMode = (mData->m->s.fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);
    558     uAliasMode |= (mData->m->s.fAliasLog ? NATAliasMode_AliasLog : 0);
    559     uAliasMode |= (mData->m->s.fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);
     544    ULONG uAliasMode = (mData->m->fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);
     545    uAliasMode |= (mData->m->fAliasLog ? NATAliasMode_AliasLog : 0);
     546    uAliasMode |= (mData->m->fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);
    560547    *aAliasMode = uAliasMode;
    561548    return S_OK;
  • trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp

    r61034 r61170  
    6565 *  @param aParent  Handle of the parent object.
    6666 */
    67 HRESULT NetworkAdapter::init(Machine *aParent, ULONG aSlot)
    68 {
    69     LogFlowThisFunc(("aParent=%p, aSlot=%d\n", aParent, aSlot));
     67HRESULT NetworkAdapter::init(Machine *aParent, ULONG uSlot)
     68{
     69    LogFlowThisFunc(("aParent=%p, uSlot=%d\n", aParent, uSlot));
    7070
    7171    ComAssertRet(aParent, E_INVALIDARG);
    7272    uint32_t maxNetworkAdapters = Global::getMaxNetworkAdapters(aParent->i_getChipsetType());
    73     ComAssertRet(aSlot < maxNetworkAdapters, E_INVALIDARG);
     73    ComAssertRet(uSlot < maxNetworkAdapters, E_INVALIDARG);
    7474
    7575    /* Enclose the state transition NotReady->InInit->Ready */
     
    8585
    8686    /* initialize data */
    87     mData->mSlot = aSlot;
     87    mData->ulSlot = uSlot;
    8888
    8989    /* default to Am79C973 */
    90     mData->mAdapterType = NetworkAdapterType_Am79C973;
     90    mData->type = NetworkAdapterType_Am79C973;
    9191
    9292    /* Confirm a successful initialization */
     
    214214    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    215215
    216     *aAdapterType = mData->mAdapterType;
     216    *aAdapterType = mData->type;
    217217
    218218    return S_OK;
     
    247247    }
    248248
    249     if (mData->mAdapterType != aAdapterType)
     249    if (mData->type != aAdapterType)
    250250    {
    251251        mData.backup();
    252         mData->mAdapterType = aAdapterType;
     252        mData->type = aAdapterType;
    253253
    254254        // leave the lock before informing callbacks
     
    268268
    269269
    270 HRESULT NetworkAdapter::getSlot(ULONG *aSlot)
    271 {
    272     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    273 
    274     *aSlot = mData->mSlot;
     270HRESULT NetworkAdapter::getSlot(ULONG *uSlot)
     271{
     272    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     273
     274    *uSlot = mData->ulSlot;
    275275
    276276    return S_OK;
     
    281281    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    282282
    283     *aEnabled = mData->mEnabled;
     283    *aEnabled = mData->fEnabled;
    284284
    285285    return S_OK;
     
    294294    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    295295
    296     if (mData->mEnabled != aEnabled)
     296    if (mData->fEnabled != aEnabled)
    297297    {
    298298        mData.backup();
    299         mData->mEnabled = aEnabled;
    300         if (aEnabled && mData->mMACAddress.isEmpty())
     299        mData->fEnabled = aEnabled;
     300        if (aEnabled && mData->strMACAddress.isEmpty())
    301301            i_generateMACAddress();
    302302
     
    320320    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    321321
    322     ComAssertRet(!mData->mEnabled || !mData->mMACAddress.isEmpty(), E_FAIL);
    323 
    324     aMACAddress = mData->mMACAddress;
     322    ComAssertRet(!mData->fEnabled || !mData->strMACAddress.isEmpty(), E_FAIL);
     323
     324    aMACAddress = mData->strMACAddress;
    325325
    326326    return S_OK;
     
    334334     * Are we supposed to generate a MAC?
    335335     */
    336     if (mData->mEnabled && aMACAddress.isEmpty())
     336    if (mData->fEnabled && aMACAddress.isEmpty())
    337337        i_generateMACAddress();
    338338    else
    339339    {
    340         if (mData->mMACAddress != aMACAddress)
     340        if (mData->strMACAddress != aMACAddress)
    341341        {
    342             if (mData->mEnabled || !aMACAddress.isEmpty())
     342            if (mData->fEnabled || !aMACAddress.isEmpty())
    343343            {
    344344                /*
     
    374374
    375375            if (SUCCEEDED(rc))
    376                 mData->mMACAddress = aMACAddress;
     376                mData->strMACAddress = aMACAddress;
    377377        }
    378378    }
     
    412412    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    413413
    414     *aAttachmentType = mData->mAttachmentType;
     414    *aAttachmentType = mData->mode;
    415415
    416416    return S_OK;
     
    425425    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    426426
    427     if (mData->mAttachmentType != aAttachmentType)
     427    if (mData->mode != aAttachmentType)
    428428    {
    429429        mData.backup();
    430430
    431431        /* there must an internal network name */
    432         if (mData->mInternalNetwork.isEmpty())
     432        if (mData->strInternalNetworkName.isEmpty())
    433433        {
    434434            Log(("Internal network name not defined, setting to default \"intnet\"\n"));
    435             mData->mInternalNetwork = "intnet";
     435            mData->strInternalNetworkName = "intnet";
    436436        }
    437437
    438438        /* there must a NAT network name */
    439         if (mData->mNATNetwork.isEmpty())
     439        if (mData->strNATNetworkName.isEmpty())
    440440        {
    441441            Log(("NAT network name not defined, setting to default \"NatNetwork\"\n"));
    442             mData->mNATNetwork = "NatNetwork";
     442            mData->strNATNetworkName = "NatNetwork";
    443443        }
    444444
    445         NetworkAttachmentType_T oldAttachmentType = mData->mAttachmentType;
    446         mData->mAttachmentType = aAttachmentType;
     445        NetworkAttachmentType_T oldAttachmentType = mData->mode;
     446        mData->mode = aAttachmentType;
    447447
    448448        // leave the lock before informing callbacks
     
    454454
    455455        if (oldAttachmentType == NetworkAttachmentType_NATNetwork)
    456             i_checkAndSwitchFromNatNetworking(mData->mNATNetwork);
     456            i_checkAndSwitchFromNatNetworking(mData->strNATNetworkName);
    457457
    458458        if (aAttachmentType == NetworkAttachmentType_NATNetwork)
    459             i_switchToNatNetworking(mData->mNATNetwork);
     459            i_switchToNatNetworking(mData->strNATNetworkName);
    460460
    461461        /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */
     
    470470    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    471471
    472     aBridgedInterface = mData->mBridgedInterface;
     472    aBridgedInterface = mData->strBridgedName;
    473473
    474474    return S_OK;
     
    483483    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    484484
    485     if (mData->mBridgedInterface != aBridgedInterface)
     485    if (mData->strBridgedName != aBridgedInterface)
    486486    {
    487487        /* if an empty/null string is to be set, bridged interface must be
    488488         * turned off */
    489489        if (aBridgedInterface.isEmpty()
    490             && mData->mAttachmentType == NetworkAttachmentType_Bridged)
     490            && mData->mode == NetworkAttachmentType_Bridged)
    491491        {
    492492            return setError(E_FAIL,
     
    495495
    496496        mData.backup();
    497         mData->mBridgedInterface = aBridgedInterface;
     497        mData->strBridgedName = aBridgedInterface;
    498498
    499499        // leave the lock before informing callbacks
     
    517517    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    518518
    519     aHostOnlyInterface = mData->mHostOnlyInterface;
     519    aHostOnlyInterface = mData->strHostOnlyName;
    520520
    521521    return S_OK;
     
    530530    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    531531
    532     if (mData->mHostOnlyInterface != aHostOnlyInterface)
     532    if (mData->strHostOnlyName != aHostOnlyInterface)
    533533    {
    534534        /* if an empty/null string is to be set, host only interface must be
    535535         * turned off */
    536536        if ( aHostOnlyInterface.isEmpty()
    537              && mData->mAttachmentType == NetworkAttachmentType_HostOnly)
     537             && mData->mode == NetworkAttachmentType_HostOnly)
    538538        {
    539539            return setError(E_FAIL,
     
    542542
    543543        mData.backup();
    544         mData->mHostOnlyInterface = aHostOnlyInterface;
     544        mData->strHostOnlyName = aHostOnlyInterface;
    545545
    546546        // leave the lock before informing callbacks
     
    565565    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    566566
    567     aInternalNetwork = mData->mInternalNetwork;
     567    aInternalNetwork = mData->strInternalNetworkName;
    568568
    569569    return S_OK;
     
    578578    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    579579
    580     if (mData->mInternalNetwork != aInternalNetwork)
     580    if (mData->strInternalNetworkName != aInternalNetwork)
    581581    {
    582582        /* if an empty/null string is to be set, internal networking must be
    583583         * turned off */
    584         if (aInternalNetwork.isEmpty() && mData->mAttachmentType == NetworkAttachmentType_Internal)
     584        if (aInternalNetwork.isEmpty() && mData->mode == NetworkAttachmentType_Internal)
    585585        {
    586586            return setError(E_FAIL,
     
    588588        }
    589589        mData.backup();
    590         mData->mInternalNetwork = aInternalNetwork;
     590        mData->strInternalNetworkName = aInternalNetwork;
    591591
    592592        // leave the lock before informing callbacks
     
    610610    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    611611
    612     aNATNetwork = mData->mNATNetwork;
     612    aNATNetwork = mData->strNATNetworkName;
    613613
    614614    return S_OK;
     
    624624    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    625625
    626     if (mData->mNATNetwork != aNATNetwork)
     626    if (mData->strNATNetworkName != aNATNetwork)
    627627    {
    628628        /* if an empty/null string is to be set, host only interface must be
    629629         * turned off */
    630630        if (aNATNetwork.isEmpty()
    631             && mData->mAttachmentType == NetworkAttachmentType_NATNetwork)
     631            && mData->mode == NetworkAttachmentType_NATNetwork)
    632632            return setError(E_FAIL,
    633633                            tr("Empty or null NAT network name is not valid"));
     
    635635        mData.backup();
    636636
    637         Bstr oldNatNetworkName = mData->mNATNetwork;
    638         mData->mNATNetwork = aNATNetwork;
     637        Bstr oldNatNetworkName = mData->strNATNetworkName;
     638        mData->strNATNetworkName = aNATNetwork;
    639639
    640640        // leave the lock before informing callbacks
     
    660660    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    661661
    662     aGenericDriver = mData->mGenericDriver;
     662    aGenericDriver = mData->strGenericDriver;
    663663
    664664    return S_OK;
     
    673673    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    674674
    675     if (mData->mGenericDriver != aGenericDriver)
     675    if (mData->strGenericDriver != aGenericDriver)
    676676    {
    677677        mData.backup();
    678         mData->mGenericDriver = aGenericDriver;
     678        mData->strGenericDriver = aGenericDriver;
    679679
    680680        /* leave the lock before informing callbacks */
     
    692692    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    693693
    694     *aConnected = mData->mCableConnected;
     694    *aConnected = mData->fCableConnected;
    695695
    696696    return S_OK;
     
    706706    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    707707
    708     if (aConnected != mData->mCableConnected)
     708    if (aConnected != mData->fCableConnected)
    709709    {
    710710        mData.backup();
    711         mData->mCableConnected = aConnected;
     711        mData->fCableConnected = aConnected;
    712712
    713713        // leave the lock before informing callbacks
     
    730730    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    731731
    732     *aSpeed = mData->mLineSpeed;
     732    *aSpeed = mData->ulLineSpeed;
    733733
    734734    return S_OK;
     
    743743    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    744744
    745     if (aSpeed != mData->mLineSpeed)
     745    if (aSpeed != mData->ulLineSpeed)
    746746    {
    747747        mData.backup();
    748         mData->mLineSpeed = aSpeed;
     748        mData->ulLineSpeed = aSpeed;
    749749
    750750        // leave the lock before informing callbacks
     
    766766    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    767767
    768     *aPromiscModePolicy = mData->mPromiscModePolicy;
     768    *aPromiscModePolicy = mData->enmPromiscModePolicy;
    769769
    770770    return S_OK;
     
    793793    {
    794794        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    795         if (aPromiscModePolicy != mData->mPromiscModePolicy)
     795        if (aPromiscModePolicy != mData->enmPromiscModePolicy)
    796796        {
    797797            mData.backup();
    798             mData->mPromiscModePolicy = aPromiscModePolicy;
     798            mData->enmPromiscModePolicy = aPromiscModePolicy;
    799799
    800800            alock.release();
     
    813813    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    814814
    815     *aEnabled = mData->mTraceEnabled;
     815    *aEnabled = mData->fTraceEnabled;
    816816
    817817    return S_OK;
     
    826826    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    827827
    828     if (aEnabled != mData->mTraceEnabled)
     828    if (aEnabled != mData->fTraceEnabled)
    829829    {
    830830        mData.backup();
    831         mData->mTraceEnabled = aEnabled;
     831        mData->fTraceEnabled = aEnabled;
    832832
    833833        // leave the lock before informing callbacks
     
    849849    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    850850
    851     aTraceFile = mData->mTraceFile;
     851    aTraceFile = mData->strTraceFile;
    852852
    853853    return S_OK;
     
    863863    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    864864
    865     if (mData->mTraceFile != aTraceFile)
     865    if (mData->strTraceFile != aTraceFile)
    866866    {
    867867        mData.backup();
    868         mData->mTraceFile = aTraceFile;
     868        mData->strTraceFile = aTraceFile;
    869869
    870870        // leave the lock before informing callbacks
     
    895895    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    896896
    897     *aBootPriority = mData->mBootPriority;
     897    *aBootPriority = mData->ulBootPriority;
    898898
    899899    return S_OK;
     
    908908    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    909909
    910     if (aBootPriority != mData->mBootPriority)
     910    if (aBootPriority != mData->ulBootPriority)
    911911    {
    912912        mData.backup();
    913         mData->mBootPriority = aBootPriority;
     913        mData->ulBootPriority = aBootPriority;
    914914
    915915        // leave the lock before informing callbacks
     
    934934    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    935935    aValue = "";
    936     settings::StringsMap::const_iterator it = mData->mGenericProperties.find(aKey);
    937     if (it != mData->mGenericProperties.end())
     936    settings::StringsMap::const_iterator it = mData->genericProperties.find(aKey);
     937    if (it != mData->genericProperties.end())
    938938        aValue = it->second; // source is a Utf8Str
    939939
     
    948948    if (FAILED(adep.rc())) return adep.rc();
    949949    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    950     bool fGenericChange = (mData->mAttachmentType == NetworkAttachmentType_Generic);
     950    bool fGenericChange = (mData->mode == NetworkAttachmentType_Generic);
    951951    /* Generic properties processing.
    952952     * Look up the old value first; if nothing's changed then do nothing.
    953953     */
    954954    Utf8Str strOldValue;
    955     settings::StringsMap::const_iterator it = mData->mGenericProperties.find(aKey);
    956     if (it != mData->mGenericProperties.end())
     955    settings::StringsMap::const_iterator it = mData->genericProperties.find(aKey);
     956    if (it != mData->genericProperties.end())
    957957        strOldValue = it->second;
    958958
     
    960960    {
    961961        if (aValue.isEmpty())
    962             mData->mGenericProperties.erase(aKey);
     962            mData->genericProperties.erase(aKey);
    963963        else
    964             mData->mGenericProperties[aKey] = aValue;
     964            mData->genericProperties[aKey] = aValue;
    965965
    966966        /* leave the lock before informing callbacks */
     
    989989    /// @todo make use of aNames according to the documentation
    990990    NOREF(aNames);
    991     aReturnNames.resize(mData->mGenericProperties.size());
    992     aReturnValues.resize(mData->mGenericProperties.size());
     991    aReturnNames.resize(mData->genericProperties.size());
     992    aReturnValues.resize(mData->genericProperties.size());
    993993
    994994    size_t i = 0;
    995995
    996     for (settings::StringsMap::const_iterator it = mData->mGenericProperties.begin();
    997          it != mData->mGenericProperties.end();
     996    for (settings::StringsMap::const_iterator it = mData->genericProperties.begin();
     997         it != mData->genericProperties.end();
    998998         ++it, ++i)
    999999    {
     
    10391039    HRESULT rc = S_OK;
    10401040
    1041     mData->mAdapterType = data.type;
    1042     mData->mEnabled = data.fEnabled;
    10431041    /* MAC address (can be null) */
    10441042    rc = i_updateMacAddress(data.strMACAddress);
    10451043    if (FAILED(rc)) return rc;
    1046     /* cable (required) */
    1047     mData->mCableConnected = data.fCableConnected;
    1048     /* line speed (defaults to 100 Mbps) */
    1049     mData->mLineSpeed = data.ulLineSpeed;
    1050     mData->mPromiscModePolicy = data.enmPromiscModePolicy;
    1051     /* tracing (defaults to false) */
    1052     mData->mTraceEnabled = data.fTraceEnabled;
    1053     mData->mTraceFile = data.strTraceFile;
    1054     /* boot priority (defaults to 0, i.e. lowest) */
    1055     mData->mBootPriority = data.ulBootPriority;
    1056     /* bandwidth group */
    1057     mData->mBandwidthGroup = data.strBandwidthGroup;
    1058     if (mData->mBandwidthGroup.isNotEmpty())
     1044
     1045    mData.assignCopy(&data);
     1046
     1047    if (mData->strBandwidthGroup.isNotEmpty())
    10591048    {
    10601049        ComObjPtr<BandwidthGroup> group;
     
    10641053    }
    10651054
     1055    // Load NAT engine settings.
    10661056    mNATEngine->i_loadSettings(data.nat);
    1067     mData->mBridgedInterface = data.strBridgedName;
    1068     mData->mInternalNetwork = data.strInternalNetworkName;
    1069     mData->mHostOnlyInterface = data.strHostOnlyName;
    1070     mData->mGenericDriver = data.strGenericDriver;
    1071     mData->mGenericProperties = data.genericProperties;
    1072     mData->mNATNetwork = data.strNATNetworkName;
    10731057
    10741058    // leave the lock before setting attachment type
     
    10971081    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    10981082
    1099     data.fEnabled = !!mData->mEnabled;
    1100     data.strMACAddress = mData->mMACAddress;
    1101     data.fCableConnected = !!mData->mCableConnected;
    1102 
    1103     data.enmPromiscModePolicy = mData->mPromiscModePolicy;
    1104     data.ulLineSpeed = mData->mLineSpeed;
    1105 
    1106     data.fTraceEnabled = !!mData->mTraceEnabled;
    1107 
    1108     data.strTraceFile = mData->mTraceFile;
    1109 
    1110     data.ulBootPriority = mData->mBootPriority;
    1111 
    1112     data.strBandwidthGroup = mData->mBandwidthGroup;
    1113 
    1114     data.type = mData->mAdapterType;
    1115 
    1116     data.mode = mData->mAttachmentType;
     1083    data = *mData.data();
    11171084
    11181085    mNATEngine->i_saveSettings(data.nat);
    1119 
    1120     data.strBridgedName = mData->mBridgedInterface;
    1121 
    1122     data.strHostOnlyName = mData->mHostOnlyInterface;
    1123 
    1124     data.strInternalNetworkName = mData->mInternalNetwork;
    1125 
    1126     data.strGenericDriver = mData->mGenericDriver;
    1127     data.genericProperties = mData->mGenericProperties;
    1128 
    1129     data.strNATNetworkName = mData->mNATNetwork;
    11301086
    11311087    return S_OK;
     
    11411097
    11421098    bool fChanged = mData.isBackedUp();
    1143     fChanged |= (mData->mAdapterType == NetworkAttachmentType_NAT? mNATEngine->i_isModified() : false);
     1099    fChanged |= (mData->type == NetworkAttachmentType_NAT? mNATEngine->i_isModified() : false);
    11441100    return fChanged;
    11451101}
     
    12171173    /* this will back up current data */
    12181174    mData.assignCopy(aThat->mData);
     1175
    12191176}
    12201177
     
    12411198        defaultType == NetworkAdapterType_I82545EM)
    12421199    {
    1243         if (e1000enabled) mData->mAdapterType = defaultType;
    1244     }
    1245     else mData->mAdapterType = defaultType;
     1200        if (e1000enabled) mData->mode = defaultType;
     1201    }
     1202    else mData->mode = defaultType;
    12461203
    12471204    /* Enable the first one adapter to the NAT */
    1248     if (mData->mSlot == 0)
    1249     {
    1250         mData->mEnabled = true;
    1251         if (mData->mMACAddress.isEmpty())
     1205    if (mData->ulSlot == 0)
     1206    {
     1207        mData->fEnabled = true;
     1208        if (mData->strMACAddress.isEmpty())
    12521209            i_generateMACAddress();
    1253         mData->mAttachmentType = NetworkAttachmentType_NAT;
    1254     }
    1255     mData->mCableConnected = true;
     1210        mData->type = NetworkAttachmentType_NAT;
     1211    }
     1212    mData->fCableConnected = true;
    12561213}
    12571214
     
    12771234    Host::i_generateMACAddress(mac);
    12781235    LogFlowThisFunc(("generated MAC: '%s'\n", mac.c_str()));
    1279     mData->mMACAddress = mac;
     1236    mData->strMACAddress = mac;
    12801237}
    12811238
     
    12881245    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    12891246
    1290     if (mData->mBandwidthGroup.isNotEmpty())
     1247    if (mData->strBandwidthGroup.isNotEmpty())
    12911248    {
    12921249        ComObjPtr<BandwidthGroup> pBwGroup;
    1293         hrc = mParent->i_getBandwidthGroup(mData->mBandwidthGroup, pBwGroup, true /* fSetError */);
     1250        hrc = mParent->i_getBandwidthGroup(mData->strBandwidthGroup, pBwGroup, true /* fSetError */);
    12941251
    12951252        Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence
     
    13181275        strBwGroup = static_cast<BandwidthGroup *>(iBw)->i_getName();
    13191276
    1320     if (mData->mBandwidthGroup != strBwGroup)
     1277    if (mData->strBandwidthGroup != strBwGroup)
    13211278    {
    13221279        ComObjPtr<BandwidthGroup> pBwGroup;
     
    13521309
    13531310    ComObjPtr<BandwidthGroup> pOldBwGroup;
    1354     if (!mData->mBandwidthGroup.isEmpty())
     1311    if (!mData->strBandwidthGroup.isEmpty())
    13551312        {
    1356             HRESULT hrc = mParent->i_getBandwidthGroup(mData->mBandwidthGroup, pOldBwGroup, false /* fSetError */);
     1313            HRESULT hrc = mParent->i_getBandwidthGroup(mData->strBandwidthGroup, pOldBwGroup, false /* fSetError */);
    13571314            NOREF(hrc);
    13581315            Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence of
     
    13641321    {
    13651322        pOldBwGroup->i_release();
    1366         mData->mBandwidthGroup = Utf8Str::Empty;
     1323        mData->strBandwidthGroup = Utf8Str::Empty;
    13671324    }
    13681325
    13691326    if (aBwGroup)
    13701327    {
    1371         mData->mBandwidthGroup = aBwGroup->i_getName();
     1328        mData->strBandwidthGroup = aBwGroup->i_getName();
    13721329        aBwGroup->i_reference();
    13731330    }
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