DHCPServerImpl.cpp revision 2f474860742ec2c8dbccf3291a73a3d7aa9e7802
/* $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->i_saveSettings();
}
{
{
case DhcpOptValue::LEGACY:
{
/*
* This is original encoding which assumed that for each
* option we know its format and so we know how option
* "value" text is to be interpreted.
*
* "2:10800" # integer 32
* "6:1.2.3.4 8.8.8.8" # array of ip-address
*/
break;
}
case DhcpOptValue::HEX:
{
/*
* This is a bypass for any option - preformatted value as
* hex string with no semantic involved in formatting the
* value for the DHCP reply.
*
* 234=68:65:6c:6c:6f:2c:20:77:6f:72:6c:64
*/
break;
}
default:
{
/*
* Try to be forward compatible.
*
* "254@42=i hope you know what this means"
*/
break;
}
}
return S_OK;
}
{
/* Indirect way to understand that we're on NAT network */
if (aOption == DhcpOpt_Router)
return mVirtualBox->i_saveSettings();
}
{
size_t i = 0;
{
}
return S_OK;
}
{
size_t i = 0;
{
}
return S_OK;
}
{
return mVirtualBox->i_saveSettings();
}
{
return mVirtualBox->i_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].text).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 */
}
{
}
{
}