DHCPServerImpl.cpp revision c7d6efcc8a689c50bad763b66b3421bd465ad83e
/* $Id$ */
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include <string>
#include "NetworkServiceRunner.h"
#include "DHCPServerImpl.h"
#include "AutoCaller.h"
#include "Logging.h"
#include <VBox/settings.h>
#include "VirtualBoxImpl.h"
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
struct DHCPServer::Data
{
};
{
m = new DHCPServer::Data();
}
DHCPServer::~DHCPServer()
{
if (m)
{
delete m;
m = NULL;
}
}
{
return BaseFinalConstruct();
}
void DHCPServer::FinalRelease()
{
uninit ();
}
void DHCPServer::uninit()
{
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
}
{
AutoInitSpan autoInitSpan(this);
/* share VirtualBox weakly (parent remains NULL so far) */
m->IPAddress = "0.0.0.0";
m->lowerIP = "0.0.0.0";
m->upperIP = "0.0.0.0";
/* Confirm a successful initialization */
return S_OK;
}
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
/* share VirtualBox weakly (parent remains NULL so far) */
m->GlobalDhcpOptions.clear();
m->VmSlot2Options.clear();
return S_OK;
}
{
AutoCaller autoCaller(this);
m->GlobalDhcpOptions.end());
m->VmSlot2Options.end());
return S_OK;
}
{
return S_OK;
}
{
return S_OK;
}
{
// save the global settings; for that we should hold only the VirtualBox lock
return rc;
}
{
return S_OK;
}
{
return S_OK;
}
{
return S_OK;
}
{
return S_OK;
}
{
m->IPAddress = aIPAddress;
// save the global settings; for that we should hold only the VirtualBox lock
return mVirtualBox->saveSettings();
}
{
/* Indirect way to understand that we're on NAT network */
if (aOption == DhcpOpt_Router)
return mVirtualBox->saveSettings();
}
{
size_t i = 0;
{
}
return S_OK;
}
{
size_t i = 0;
{
}
return S_OK;
}
{
return mVirtualBox->saveSettings();
}
{
return mVirtualBox->saveSettings();
}
/**
* this is mapping (vm, slot)
*/
{
size_t i = 0;
{
}
return S_OK;
}
{
{
continue;
continue;
break;
aOption);
} /* end of for */
return hrc;
}
{
}
{
/* Silently ignore attempts to run disabled servers. */
if (!m->enabled)
return S_OK;
/* Commmon Network Settings */
if (!aTrunkName.isEmpty())
/* XXX: should this MAC default initialization moved to NetworkServiceRunner? */
char strMAC[32];
m->dhcp.setOption(NetworkServiceRunner::kNsrIpNetmask, Utf8Str(m->GlobalDhcpOptions[DhcpOpt_SubnetMask]).c_str());
/* XXX: This parameters Dhcp Server will fetch via API */
//m->dhcp.detachFromServer(); /* need to do this to avoid server shutdown on runner destruction */
}
{
}
{
}