VirtualBox

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

8238 VBoxSVC settings - NetworkAdapterImpl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
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