DHCPServerRunner.cpp revision c7814cf6e1240a519cbec0441e033d0e2470ed00
/* $Id$ */
/** @file
* VirtualBox Main - interface for VBox DHCP server
*/
/*
* Copyright (C) 2009-2012 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 "DHCPServerRunner.h"
struct ARGDEF
{
const char * Name;
};
#ifdef RT_OS_WINDOWS
# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP.exe"
#else
# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP"
#endif
static const ARGDEF g_aArgDefs[] =
{
{DHCPCFG_NAME, "--name"},
{DHCPCFG_NETNAME, "--network"},
{DHCPCFG_TRUNKTYPE, "--trunk-type"},
{DHCPCFG_TRUNKNAME, "--trunk-name"},
{DHCPCFG_MACADDRESS, "--mac-address"},
{DHCPCFG_IPADDRESS, "--ip-address"},
{DHCPCFG_LEASEDB, "--lease-db"},
{DHCPCFG_VERBOSE, "--verbose"},
{DHCPCFG_BEGINCONFIG, "--begin-config"},
{DHCPCFG_GATEWAY, "--gateway"},
{DHCPCFG_LOWERIP, "--lower-ip"},
{DHCPCFG_UPPERIP, "--upper-ip"},
{DHCPCFG_NETMASK, "--netmask"},
{DHCPCFG_HELP, "--help"},
{DHCPCFG_VERSION, "--version"}
};
{
for (unsigned i = 0; i < RT_ELEMENTS(g_aArgDefs); i++)
return &g_aArgDefs[i];
return NULL;
}
{
for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++)
{
mOptionEnabled[i] = false;
}
}
void DHCPServerRunner::detachFromServer()
{
}
int DHCPServerRunner::start()
{
if (isRunning())
return VINF_ALREADY_INITIALIZED;
/* get the path to the executable */
char exePathBuf[RTPATH_MAX];
if (suffix)
{
suffix++;
}
else
int index = 0;
for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++)
{
if (mOptionEnabled[i])
{
if (!pArgDef)
continue;
/* value can be null for e.g. --begin-config has no value
* and thus check the mOptions string length here
*/
}
}
if (RT_FAILURE(rc))
return rc;
}
int DHCPServerRunner::stop()
{
if (!isRunning())
return VINF_OBJECT_DESTROYED;
return rc;
}
bool DHCPServerRunner::isRunning()
{
if (mProcess == NIL_RTPROCESS)
return false;
if (rc == VERR_PROCESS_RUNNING)
return true;
return false;
}