VirtualBox

Changeset 17881 in vbox


Ignore:
Timestamp:
Mar 14, 2009 11:33:49 PM (16 years ago)
Author:
vboxsync
Message:

dhcp settings

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

Legend:

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

    r17875 r17881  
    2525#include "Logging.h"
    2626
     27#include <VBox/settings.h>
     28
    2729// constructor / destructor
    2830/////////////////////////////////////////////////////////////////////////////
     
    4042}
    4143
    42 HRESULT DhcpServer::init(IN_BSTR aName)
    43 {
    44     return E_NOTIMPL;
    45 }
    46 
    47 HRESULT DhcpServer::init(const settings::Key &aNode)
    48 {
    49     return E_NOTIMPL;
     44HRESULT DhcpServer::init(VirtualBox *aVirtualBox, IN_BSTR aName)
     45{
     46    AssertReturn (aName != NULL, E_INVALIDARG);
     47
     48    AutoInitSpan autoInitSpan (this);
     49    AssertReturn (autoInitSpan.isOk(), E_FAIL);
     50
     51    unconst(mName) = aName;
     52
     53    /* register with VirtualBox early, since uninit() will
     54     * unconditionally unregister on failure */
     55    aVirtualBox->addDependentChild (this);
     56
     57    /* Confirm a successful initialization */
     58    autoInitSpan.setSucceeded();
     59
     60    return S_OK;
     61}
     62
     63HRESULT DhcpServer::init(VirtualBox *aVirtualBox, const settings::Key &aNode)
     64{
     65    using namespace settings;
     66
     67    /* Enclose the state transition NotReady->InInit->Ready */
     68    AutoInitSpan autoInitSpan (this);
     69    AssertReturn (autoInitSpan.isOk(), E_FAIL);
     70
     71    aVirtualBox->addDependentChild (this);
     72
     73    unconst(mName) = aNode.stringValue ("networkName");
     74    m.IPAddress = aNode.stringValue ("IPAddress");
     75    m.networkMask = aNode.stringValue ("networkMask");
     76    m.enabled = aNode.value <BOOL> ("enabled");
     77    m.FromIPAddress = aNode.stringValue ("lowerIp");
     78    m.ToIPAddress = aNode.stringValue ("upperIp");
     79
     80    autoInitSpan.setSucceeded();
     81
     82    return S_OK;
    5083}
    5184
    5285HRESULT DhcpServer::saveSettings (settings::Key &aParentNode)
    5386{
    54     return E_NOTIMPL;
     87    using namespace settings;
     88
     89    AssertReturn (!aParentNode.isNull(), E_FAIL);
     90
     91    AutoCaller autoCaller (this);
     92    CheckComRCReturnRC (autoCaller.rc());
     93
     94    AutoReadLock alock (this);
     95
     96    Key aNode = aParentNode.appendKey ("DhcpServer");
     97    /* required */
     98    aNode.setValue <Bstr> ("networkName", mName);
     99    aNode.setValue <Bstr> ("IPAddress", m.IPAddress);
     100    aNode.setValue <Bstr> ("networkMask", m.networkMask);
     101    if(!m.FromIPAddress.isNull())
     102        aNode.setValue <Bstr> ("FromIPAddress", m.FromIPAddress);
     103    if(!m.ToIPAddress.isNull())
     104        aNode.setValue <Bstr> ("ToIPAddress", m.ToIPAddress);
     105
     106    return S_OK;
    55107}
    56108
     
    146198STDMETHODIMP DhcpServer::SetConfiguration (IN_BSTR aIPAddress, IN_BSTR aNetworkMask, IN_BSTR aFromIPAddress, IN_BSTR aToIPAddress)
    147199{
    148     return E_NOTIMPL;
    149 }
     200    AssertReturn (aIPAddress != NULL, E_INVALIDARG);
     201    AssertReturn (aNetworkMask != NULL, E_INVALIDARG);
     202    AssertReturn (aFromIPAddress != NULL, E_INVALIDARG);
     203    AssertReturn (aToIPAddress != NULL, E_INVALIDARG);
     204
     205    m.IPAddress = aIPAddress;
     206    m.networkMask = aNetworkMask;
     207    m.FromIPAddress = aFromIPAddress;
     208    m.ToIPAddress = aToIPAddress;
     209
     210    return S_OK;
     211}
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r17876 r17881  
    31563156                ComObjPtr<DhcpServer> dhcpServer;
    31573157                dhcpServer.createObject();
    3158                 rc = dhcpServer->init (*it);
     3158                rc = dhcpServer->init (this, *it);
    31593159                CheckComRCBreakRC (rc);
    31603160
     
    46634663    ComObjPtr<DhcpServer> dhcpServer;
    46644664    dhcpServer.createObject();
    4665     HRESULT rc = dhcpServer->init (aName);
     4665    HRESULT rc = dhcpServer->init (this, aName);
    46664666    CheckComRCReturnRC (rc);
    46674667
     
    47654765    if(SUCCEEDED(rc))
    47664766    {
    4767         return E_FAIL;
     4767        return E_INVALIDARG;
    47684768    }
    47694769
  • trunk/src/VBox/Main/include/DhcpServerImpl.h

    r17875 r17881  
    6060    void FinalRelease();
    6161
    62     HRESULT init(IN_BSTR aName);
    63     HRESULT init(const settings::Key &aNode);
     62    HRESULT init(VirtualBox *aVirtualBox, IN_BSTR aName);
     63    HRESULT init(VirtualBox *aVirtualBox, const settings::Key &aNode);
    6464    HRESULT saveSettings (settings::Key &aParentNode);
    6565
  • trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd

    r17872 r17881  
    257257<xsd:complexType name="TDhcpServer">
    258258  <xsd:attribute name="networkName" type="xsd:string"  use="required"/>
    259   <xsd:attribute name="lowerIp"     type="xsd:string"  use="optional"/>
    260   <xsd:attribute name="upperIp"     type="xsd:string"  use="optional"/>
     259  <xsd:attribute name="lowerIp"     type="xsd:string"  use="required"/>
     260  <xsd:attribute name="upperIp"     type="xsd:string"  use="required"/>
    261261  <xsd:attribute name="IPAddress"   type="xsd:string"  use="required"/>
    262262  <xsd:attribute name="networkMask" type="xsd:string"  use="required"/>
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