summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2018-11-16 11:33:38 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2018-11-16 11:33:38 +0000
commit499cbfa753a92d50ded8aa8f5eb5c516bebee5ff (patch)
treeb185dadef3011ad72b46b9c681f628e4e3d279dc /src
parent511c14c5ba2610ef3d3c977ba94e248b5b661a33 (diff)
downloadVirtualBox-svn-499cbfa753a92d50ded8aa8f5eb5c516bebee5ff.tar.gz
Main/DHCPD: bugref:9288 Use new implementation of DHCP server.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@75512 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src')
-rw-r--r--src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp26
-rw-r--r--src/VBox/Main/Makefile.kmk1
-rw-r--r--src/VBox/Main/idl/VirtualBox.xidl11
-rw-r--r--src/VBox/Main/include/DHCPServerImpl.h2
-rw-r--r--src/VBox/Main/include/NetworkServiceRunner.h1
-rw-r--r--src/VBox/Main/src-server/DHCPServerImpl.cpp149
-rw-r--r--src/VBox/Main/src-server/NetworkServiceRunner.cpp6
-rw-r--r--src/VBox/NetworkServices/Dhcpd/Db.cpp2
-rw-r--r--src/VBox/NetworkServices/Dhcpd/Defs.h6
-rw-r--r--src/VBox/NetworkServices/Dhcpd/DhcpOptions.cpp2
-rw-r--r--src/VBox/NetworkServices/Dhcpd/Makefile.kmk61
-rw-r--r--src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp11
-rw-r--r--src/VBox/NetworkServices/Makefile.kmk6
13 files changed, 243 insertions, 41 deletions
diff --git a/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp b/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp
index 57c256ae096..a8419f0b8fc 100644
--- a/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp
+++ b/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp
@@ -51,7 +51,8 @@ typedef enum enMainOpCodes
{
OP_ADD = 1000,
OP_REMOVE,
- OP_MODIFY
+ OP_MODIFY,
+ OP_RESTART
} OPCODE;
typedef std::pair<DhcpOpt_T, std::string> DhcpOptSpec;
@@ -318,6 +319,7 @@ static RTEXITCODE handleOp(HandlerArg *a, OPCODE enmCode, int iStart)
return errorSyntax(USAGE_DHCPSERVER, "You need to specify either --netname or --ifname to identify the DHCP server");
if( enmCode != OP_REMOVE
+ && enmCode != OP_RESTART
&& GlobalDhcpOptions.empty()
&& VmSlot2Options.empty())
{
@@ -373,7 +375,19 @@ static RTEXITCODE handleOp(HandlerArg *a, OPCODE enmCode, int iStart)
return errorArgument("DHCP server does not exist");
}
- if(enmCode != OP_REMOVE)
+ if (enmCode == OP_RESTART)
+ {
+ CHECK_ERROR(svr, Restart());
+ if(FAILED(rc))
+ return errorArgument("Failed to restart server");
+ }
+ else if (enmCode == OP_REMOVE)
+ {
+ CHECK_ERROR(a->virtualBox, RemoveDHCPServer(svr));
+ if(FAILED(rc))
+ return errorArgument("Failed to remove server");
+ }
+ else
{
if (pIp || pNetmask || pLowerIp || pUpperIp)
{
@@ -424,12 +438,6 @@ static RTEXITCODE handleOp(HandlerArg *a, OPCODE enmCode, int iStart)
}
}
}
- else
- {
- CHECK_ERROR(a->virtualBox, RemoveDHCPServer(svr));
- if(FAILED(rc))
- return errorArgument("Failed to remove server");
- }
return RTEXITCODE_SUCCESS;
}
@@ -447,6 +455,8 @@ RTEXITCODE handleDHCPServer(HandlerArg *a)
rcExit = handleOp(a, OP_ADD, 1);
else if (strcmp(a->argv[0], "remove") == 0)
rcExit = handleOp(a, OP_REMOVE, 1);
+ else if (strcmp(a->argv[0], "restart") == 0)
+ rcExit = handleOp(a, OP_RESTART, 1);
else
rcExit = errorSyntax(USAGE_DHCPSERVER, "Invalid parameter '%s'", Utf8Str(a->argv[0]).c_str());
diff --git a/src/VBox/Main/Makefile.kmk b/src/VBox/Main/Makefile.kmk
index 9b5197fb3c8..c29e02a69f4 100644
--- a/src/VBox/Main/Makefile.kmk
+++ b/src/VBox/Main/Makefile.kmk
@@ -78,6 +78,7 @@ VBOX_MAIN_DEFS += \
$(if $(VBOX_WITH_GUEST_PROPS_RDONLY_GUEST),VBOX_WITH_GUEST_PROPS_RDONLY_GUEST,) \
$(if $(VBOX_WITH_HGCM),VBOX_WITH_HGCM,) \
$(if $(VBOX_WITH_HOSTNETIF_API),VBOX_WITH_HOSTNETIF_API,) \
+ $(if $(VBOX_WITH_DHCPD),VBOX_WITH_DHCPD,) \
$(if $(VBOX_WITH_LIVE_MIGRATION),VBOX_WITH_LIVE_MIGRATION,) \
$(if $(VBOX_WITH_MIDL_PROXY_STUB),VBOX_WITH_MIDL_PROXY_STUB,) \
$(if $(VBOX_WITH_NETFLT),VBOX_WITH_NETFLT,) \
diff --git a/src/VBox/Main/idl/VirtualBox.xidl b/src/VBox/Main/idl/VirtualBox.xidl
index 5c2b96c1f9f..2c0971c099c 100644
--- a/src/VBox/Main/idl/VirtualBox.xidl
+++ b/src/VBox/Main/idl/VirtualBox.xidl
@@ -1790,7 +1790,7 @@
<interface
name="IDHCPServer" extends="$unknown"
- uuid="00c8f974-92c5-44a1-8f3f-702469fdd04b"
+ uuid="197717d2-a742-4966-a529-d1467e903feb"
wsmap="managed"
reservedMethods="2" reservedAttributes="6"
>
@@ -1955,6 +1955,15 @@
</result>
</desc>
</method>
+
+ <method name="restart">
+ <desc>
+ Restart running DHCP server process.
+ <result name="E_FAIL">
+ Failed to restart the process.
+ </result>
+ </desc>
+ </method>
</interface>
<interface
diff --git a/src/VBox/Main/include/DHCPServerImpl.h b/src/VBox/Main/include/DHCPServerImpl.h
index 688f32e7753..3e31a5e8186 100644
--- a/src/VBox/Main/include/DHCPServerImpl.h
+++ b/src/VBox/Main/include/DHCPServerImpl.h
@@ -49,6 +49,7 @@ public:
static const std::string kDsrKeyGateway;
static const std::string kDsrKeyLowerIp;
static const std::string kDsrKeyUpperIp;
+ static const std::string kDsrKeyConfig;
};
/**
@@ -124,6 +125,7 @@ private:
const com::Utf8Str &aTrunkName,
const com::Utf8Str &aTrunkType);
HRESULT stop();
+ HRESULT restart();
struct Data;
Data *m;
diff --git a/src/VBox/Main/include/NetworkServiceRunner.h b/src/VBox/Main/include/NetworkServiceRunner.h
index 19e2d49869a..6841d916c67 100644
--- a/src/VBox/Main/include/NetworkServiceRunner.h
+++ b/src/VBox/Main/include/NetworkServiceRunner.h
@@ -35,6 +35,7 @@ public:
virtual ~NetworkServiceRunner();
int setOption(const std::string& key, const std::string& val);
+ void clearOptions();
int start(bool aKillProcOnStop);
int stop();
diff --git a/src/VBox/Main/src-server/DHCPServerImpl.cpp b/src/VBox/Main/src-server/DHCPServerImpl.cpp
index e9fc1ab2b2d..8d3dc2c4e41 100644
--- a/src/VBox/Main/src-server/DHCPServerImpl.cpp
+++ b/src/VBox/Main/src-server/DHCPServerImpl.cpp
@@ -24,8 +24,11 @@
#include "Logging.h"
#include <iprt/asm.h>
+#include <iprt/file.h>
#include <iprt/net.h>
+#include <iprt/path.h>
#include <iprt/cpp/utils.h>
+#include <iprt/cpp/xml.h>
#include <VBox/com/array.h>
#include <VBox/settings.h>
@@ -37,6 +40,7 @@
const std::string DHCPServerRunner::kDsrKeyGateway = "--gateway";
const std::string DHCPServerRunner::kDsrKeyLowerIp = "--lower-ip";
const std::string DHCPServerRunner::kDsrKeyUpperIp = "--upper-ip";
+const std::string DHCPServerRunner::kDsrKeyConfig = "--config";
struct DHCPServer::Data
@@ -44,7 +48,9 @@ struct DHCPServer::Data
Data()
: enabled(FALSE)
, router(false)
- {}
+ {
+ tempConfigFileName[0] = '\0';
+ }
Utf8Str IPAddress;
Utf8Str lowerIP;
@@ -56,6 +62,11 @@ struct DHCPServer::Data
settings::DhcpOptionMap GlobalDhcpOptions;
settings::VmSlot2OptionsMap VmSlot2Options;
+
+ char tempConfigFileName[RTPATH_MAX];
+ com::Utf8Str networkName;
+ com::Utf8Str trunkName;
+ com::Utf8Str trunkType;
};
@@ -98,6 +109,9 @@ void DHCPServer::uninit()
if (autoUninitSpan.uninitDone())
return;
+ if (m->dhcp.isRunning())
+ stop();
+
unconst(mVirtualBox) = NULL;
}
@@ -598,6 +612,30 @@ HRESULT DHCPServer::getEventSource(ComPtr<IEventSource> &aEventSource)
}
+DECLINLINE(void) addOptionChild(xml::ElementNode *pParent, uint32_t OptCode, const settings::DhcpOptValue &OptValue)
+{
+ xml::ElementNode *pOption = pParent->createChild("Option");
+ pOption->setAttribute("name", OptCode);
+ pOption->setAttribute("encoding", OptValue.encoding);
+ pOption->setAttribute("value", OptValue.text.c_str());
+}
+
+
+HRESULT DHCPServer::restart()
+{
+ if (!m->dhcp.isRunning())
+ return E_FAIL;
+ /*
+ * Disabled servers will be brought down, but won't be restarted.
+ * (see DHCPServer::start)
+ */
+ HRESULT hrc = stop();
+ if (SUCCEEDED(hrc))
+ hrc = start(m->networkName, m->trunkName, m->trunkType);
+ return hrc;
+}
+
+
HRESULT DHCPServer::start(const com::Utf8Str &aNetworkName,
const com::Utf8Str &aTrunkName,
const com::Utf8Str &aTrunkType)
@@ -606,6 +644,107 @@ HRESULT DHCPServer::start(const com::Utf8Str &aNetworkName,
if (!m->enabled)
return S_OK;
+ /*
+ * @todo: the existing code cannot handle concurrent attempts to start DHCP server.
+ * Note that technically it may receive different parameters from different callers.
+ */
+ m->networkName = aNetworkName;
+ m->trunkName = aTrunkName;
+ m->trunkType = aTrunkType;
+
+ m->dhcp.clearOptions();
+#ifdef VBOX_WITH_DHCPD
+ int rc = RTPathTemp(m->tempConfigFileName, sizeof(m->tempConfigFileName));
+ if (RT_FAILURE(rc))
+ return E_FAIL;
+ rc = RTPathAppend(m->tempConfigFileName, sizeof(m->tempConfigFileName), "dhcp-config-XXXXX.xml");
+ if (RT_FAILURE(rc))
+ {
+ m->tempConfigFileName[0] = '\0';
+ return E_FAIL;
+ }
+ rc = RTFileCreateTemp(m->tempConfigFileName, 0600);
+ if (RT_FAILURE(rc))
+ {
+ m->tempConfigFileName[0] = '\0';
+ return E_FAIL;
+ }
+
+ xml::Document doc;
+ xml::ElementNode *pElmRoot = doc.createRootElement("DHCPServer");
+ pElmRoot->setAttribute("networkName", m->networkName.c_str());
+ if (!m->trunkName.isEmpty())
+ pElmRoot->setAttribute("trunkName", m->trunkName.c_str());
+ pElmRoot->setAttribute("trunkType", m->trunkType.c_str());
+ pElmRoot->setAttribute("IPAddress", Utf8Str(m->IPAddress).c_str());
+ pElmRoot->setAttribute("networkMask", Utf8Str(m->GlobalDhcpOptions[DhcpOpt_SubnetMask].text).c_str());
+ pElmRoot->setAttribute("lowerIP", Utf8Str(m->lowerIP).c_str());
+ pElmRoot->setAttribute("upperIP", Utf8Str(m->upperIP).c_str());
+
+ /* Process global options */
+ xml::ElementNode *pOptions = pElmRoot->createChild("Options");
+ // settings::DhcpOptionMap::const_iterator itGlobal;
+ for (settings::DhcpOptionMap::const_iterator it = m->GlobalDhcpOptions.begin();
+ it != m->GlobalDhcpOptions.end();
+ ++it)
+ addOptionChild(pOptions, (*it).first, (*it).second);
+
+ /* Process network-adapter-specific options */
+ AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+ HRESULT hrc = S_OK;
+ ComPtr<IMachine> machine;
+ ComPtr<INetworkAdapter> nic;
+ settings::VmSlot2OptionsIterator it;
+ for(it = m->VmSlot2Options.begin(); it != m->VmSlot2Options.end(); ++it)
+ {
+ alock.release();
+ hrc = mVirtualBox->FindMachine(Bstr(it->first.VmName).raw(), machine.asOutParam());
+ alock.acquire();
+
+ if (FAILED(hrc))
+ continue;
+
+ alock.release();
+ hrc = machine->GetNetworkAdapter(it->first.Slot, nic.asOutParam());
+ alock.acquire();
+
+ if (FAILED(hrc))
+ continue;
+
+ com::Bstr mac;
+
+ alock.release();
+ hrc = nic->COMGETTER(MACAddress)(mac.asOutParam());
+ alock.acquire();
+
+ if (FAILED(hrc)) /* no MAC address ??? */
+ continue;
+
+ /* Convert MAC address from XXXXXXXXXXXX to XX:XX:XX:XX:XX:XX */
+ Utf8Str strMacWithoutColons(mac);
+ const char *pszSrc = strMacWithoutColons.c_str();
+ RTMAC binaryMac;
+ if (RTStrConvertHexBytes(pszSrc, &binaryMac, sizeof(binaryMac), 0) != VINF_SUCCESS)
+ continue;
+ char szMac[18]; /* "XX:XX:XX:XX:XX:XX" */
+ if (RTStrPrintHexBytes(szMac, sizeof(szMac), &binaryMac, sizeof(binaryMac), RTSTRPRINTHEXBYTES_F_SEP_COLON) != VINF_SUCCESS)
+ continue;
+
+ xml::ElementNode *pMacConfig = pElmRoot->createChild("Config");
+ pMacConfig->setAttribute("MACAddress", szMac);
+
+ com::Utf8Str encodedOption;
+ settings::DhcpOptionMap &map = i_findOptMapByVmNameSlot(it->first.VmName, it->first.Slot);
+ settings::DhcpOptionMap::const_iterator itAdapterOption;
+ for (itAdapterOption = map.begin(); itAdapterOption != map.end(); ++itAdapterOption)
+ addOptionChild(pMacConfig, (*itAdapterOption).first, (*itAdapterOption).second);
+ }
+
+ xml::XmlFileWriter writer(doc);
+ writer.write(m->tempConfigFileName, true);
+
+ m->dhcp.setOption(DHCPServerRunner::kDsrKeyConfig, m->tempConfigFileName);
+#else /* !VBOX_WITH_DHCPD */
/* Commmon Network Settings */
m->dhcp.setOption(NetworkServiceRunner::kNsrKeyNetwork, aNetworkName.c_str());
@@ -627,6 +766,7 @@ HRESULT DHCPServer::start(const com::Utf8Str &aNetworkName,
m->dhcp.setOption(NetworkServiceRunner::kNsrIpNetmask, Utf8Str(m->GlobalDhcpOptions[DhcpOpt_SubnetMask].text).c_str());
m->dhcp.setOption(DHCPServerRunner::kDsrKeyLowerIp, Utf8Str(m->lowerIP).c_str());
m->dhcp.setOption(DHCPServerRunner::kDsrKeyUpperIp, Utf8Str(m->upperIP).c_str());
+#endif /* !VBOX_WITH_DHCPD */
/* XXX: This parameters Dhcp Server will fetch via API */
return RT_FAILURE(m->dhcp.start(!m->router /* KillProcOnExit */)) ? E_FAIL : S_OK;
@@ -636,6 +776,13 @@ HRESULT DHCPServer::start(const com::Utf8Str &aNetworkName,
HRESULT DHCPServer::stop (void)
{
+#ifdef VBOX_WITH_DHCPD
+ if (m->tempConfigFileName[0])
+ {
+ RTFileDelete(m->tempConfigFileName);
+ m->tempConfigFileName[0] = 0;
+ }
+#endif /* VBOX_WITH_DHCPD */
return RT_FAILURE(m->dhcp.stop()) ? E_FAIL : S_OK;
}
diff --git a/src/VBox/Main/src-server/NetworkServiceRunner.cpp b/src/VBox/Main/src-server/NetworkServiceRunner.cpp
index 9b01085d73b..8ecc05abd82 100644
--- a/src/VBox/Main/src-server/NetworkServiceRunner.cpp
+++ b/src/VBox/Main/src-server/NetworkServiceRunner.cpp
@@ -68,6 +68,12 @@ int NetworkServiceRunner::setOption(const std::string& key, const std::string& v
}
+void NetworkServiceRunner::clearOptions()
+{
+ m->mOptions.clear();
+}
+
+
void NetworkServiceRunner::detachFromServer()
{
m->mProcess = NIL_RTPROCESS;
diff --git a/src/VBox/NetworkServices/Dhcpd/Db.cpp b/src/VBox/NetworkServices/Dhcpd/Db.cpp
index d327daed73e..d53f990fcb1 100644
--- a/src/VBox/NetworkServices/Dhcpd/Db.cpp
+++ b/src/VBox/NetworkServices/Dhcpd/Db.cpp
@@ -290,7 +290,7 @@ Binding *Binding::fromXML(const xml::ElementNode *ndLease)
* Lease/Time
*/
const xml::ElementNode *ndTime = ndLease->findChildElement("Time");
- if (time == NULL)
+ if (ndTime == NULL)
return NULL;
/*
diff --git a/src/VBox/NetworkServices/Dhcpd/Defs.h b/src/VBox/NetworkServices/Dhcpd/Defs.h
index 275ff0c3bbe..4adb30c122c 100644
--- a/src/VBox/NetworkServices/Dhcpd/Defs.h
+++ b/src/VBox/NetworkServices/Dhcpd/Defs.h
@@ -26,12 +26,16 @@
#include <memory>
#include <vector>
+#ifdef _MSC_VER
+# define __func__ __FUNCTION__
+#endif
+
typedef std::vector<uint8_t> octets_t;
typedef std::map<uint8_t, octets_t> rawopts_t;
class DhcpOption;
-typedef std::map<uint8_t, std::shared_ptr<DhcpOption>> optmap_t;
+typedef std::map<uint8_t, std::shared_ptr<DhcpOption> > optmap_t;
inline bool operator==(const RTMAC &l, const RTMAC &r)
{
diff --git a/src/VBox/NetworkServices/Dhcpd/DhcpOptions.cpp b/src/VBox/NetworkServices/Dhcpd/DhcpOptions.cpp
index 80729619248..29ca9b37838 100644
--- a/src/VBox/NetworkServices/Dhcpd/DhcpOptions.cpp
+++ b/src/VBox/NetworkServices/Dhcpd/DhcpOptions.cpp
@@ -35,7 +35,7 @@ optmap_t &operator<<(optmap_t &optmap, DhcpOption *option)
optmap_t &operator<<(optmap_t &optmap, const std::shared_ptr<DhcpOption> &option)
{
- if (option == NULL)
+ if (option == nullptr)
return optmap;
if (option->present())
diff --git a/src/VBox/NetworkServices/Dhcpd/Makefile.kmk b/src/VBox/NetworkServices/Dhcpd/Makefile.kmk
index 9b9e9dba95a..a9f11d2b21d 100644
--- a/src/VBox/NetworkServices/Dhcpd/Makefile.kmk
+++ b/src/VBox/NetworkServices/Dhcpd/Makefile.kmk
@@ -28,41 +28,54 @@ include $(KBUILD_PATH)/subheader.kmk
ifdef VBOX_WITH_HARDENING
PROGRAMS += VBoxNetDhcpdHardened
- VBoxNetDhcpdHardened_TEMPLATE = VBOXR3HARDENEDEXE
- VBoxNetDhcpdHardened_NAME = VBoxNetDhcpd
- VBoxNetDhcpdHardened_DEFS = SERVICE_NAME=\"VBoxNetDhcpd\"
- VBoxNetDhcpdHardened_SOURCES = VBoxNetDhcpdHardened.cpp
- VBoxNetDhcpdHardened_SOURCES.win = $(VBoxNetLwipNAT_0_OUTDIR)/VBoxNetDhcpd-icon.rc
- VBoxNetDhcpdHardened_LDFLAGS.win = /SUBSYSTEM:windows
+ DLLS += VBoxNetDhcpd
else
PROGRAMS += VBoxNetDhcpd
endif
- VBoxNetDhcpd_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBOXMAINDLL,VBOXMAINCLIENTEXE)
- VBoxNetDhcpd_NAME := VBoxNetDhcpd
+ VBoxNetDhcpdHardened_TEMPLATE = VBOXR3HARDENEDEXE
+ VBoxNetDhcpdHardened_NAME = VBoxNetDHCP
+ VBoxNetDhcpdHardened_DEFS = SERVICE_NAME=\"VBoxNetDhcpd\"
+ VBoxNetDhcpdHardened_SOURCES = VBoxNetDhcpdHardened.cpp
+ VBoxNetDhcpdHardened_SOURCES.win = $(VBoxNetDhcpd_0_OUTDIR)/VBoxNetDhcpd-icon.rc
+ VBoxNetDhcpdHardened_LDFLAGS.win = /SUBSYSTEM:windows
+
+ if1of ($(KBUILD_TARGET),win linux solaris)
+ VBoxNetDhcpd_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBoxR3DllDhcpd,VBoxR3ExeDhcpd)
+ else
+ VBoxNetDhcpd_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBoxR3Dll,VBOXR3EXE)
+ endif
+ VBoxNetDhcpd_NAME = VBoxNetDHCP
# VBoxNetDhcpd_DEFS = IPv6
- # VBoxNetLwipNAT_DEFS.linux = WITH_VALGRIND
- VBoxNetDhcpd_DEFS.win = VBOX_COM_OUTOFPROC_MODULE _WIN32_WINNT=0x501 # Windows XP
+ # VBoxNetDhcpd_DEFS.linux = WITH_VALGRIND
+ #VBoxNetDhcpd_DEFS.win = VBOX_COM_OUTOFPROC_MODULE _WIN32_WINNT=0x501 # Windows XP
# (current dir is for for lwipopts.h)
VBoxNetDhcpd_INCS += . $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_INCS))
- VBoxNetDhcpd_SOURCES =
- VBoxNetDhcpd_SOURCES += ClientId.cpp
- VBoxNetDhcpd_SOURCES += Config.cpp
- VBoxNetDhcpd_SOURCES += DHCPD.cpp
- VBoxNetDhcpd_SOURCES += Db.cpp
- VBoxNetDhcpd_SOURCES += DhcpMessage.cpp
- VBoxNetDhcpd_SOURCES += DhcpOptions.cpp
- VBoxNetDhcpd_SOURCES += IPv4Pool.cpp
- VBoxNetDhcpd_SOURCES += TimeStamp.cpp
- VBoxNetDhcpd_SOURCES += VBoxNetDhcpd.cpp
- VBoxNetDhcpd_SOURCES += $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_SOURCES))
+ VBoxNetDhcpd_DEFS = KBUILD_TYPE=\"$(KBUILD_TYPE)\"
+ ifneq ($(KBUILD_TARGET),win)
+ VBoxNetDhcpd_DEFS += VBOX_WITH_XPCOM
+ VBoxNetDhcpd_INCS += $(VBOX_XPCOM_INCS)
+ VBoxNetDhcpd_CXXFLAGS += -std=c++11
+ endif
+ VBoxNetDhcpd_SOURCES = ../../Main/glue/VBoxLogRelCreate.cpp \
+ ../../Main/glue/GetVBoxUserHomeDirectory.cpp \
+ ClientId.cpp \
+ Config.cpp \
+ DHCPD.cpp \
+ Db.cpp \
+ DhcpMessage.cpp \
+ DhcpOptions.cpp \
+ IPv4Pool.cpp \
+ TimeStamp.cpp \
+ VBoxNetDhcpd.cpp \
+ $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_SOURCES))
- VBoxNetLwipNAT_LIBS = $(LIB_RUNTIME)
+ VBoxNetDhcpd_LIBS = $(LIB_RUNTIME)
- VBoxNetLwipNAT_LIBS.solaris += socket nsl
- VBoxNetLwipNAT_LDFLAGS.win = /SUBSYSTEM:windows
+ VBoxNetDhcpd_LIBS.solaris += socket nsl
+ VBoxNetDhcpd_LDFLAGS.win = /SUBSYSTEM:windows
ifeq ($(KBUILD_TARGET),win)
# Icon include file.
diff --git a/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp b/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
index 187b3aea4d1..8a022219712 100644
--- a/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
+++ b/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
@@ -51,6 +51,11 @@ extern "C"
#include <vector>
#include <memory>
+#ifdef RT_OS_WINDOWS /* WinMain */
+#undef htonl
+#undef ntohl
+# include <iprt/win/windows.h>
+#endif
struct delete_pbuf
{
@@ -447,7 +452,7 @@ int VBoxNetDhcpd::ifProcessInput()
abHdrScratch,
i, cSegs,
&cbSegFrame);
- ifInput(pvSegFrame, cbFrame);
+ ifInput(pvSegFrame, (uint32_t)cbFrame);
}
}
}
@@ -737,10 +742,10 @@ void VBoxNetDhcpd::dhcp4Recv(struct udp_pcb *pcb, struct pbuf *p,
return;
unique_ptr_pbuf q ( pbuf_alloc(PBUF_RAW, (u16_t)data.size(), PBUF_RAM) );
- if (q == NULL)
+ if (q == nullptr)
return;
- error = pbuf_take(q.get(), &data.front(), data.size());
+ error = pbuf_take(q.get(), &data.front(), (u16_t)data.size());
if (error != ERR_OK)
return;
diff --git a/src/VBox/NetworkServices/Makefile.kmk b/src/VBox/NetworkServices/Makefile.kmk
index 658a6934b8e..44bf3e8805b 100644
--- a/src/VBox/NetworkServices/Makefile.kmk
+++ b/src/VBox/NetworkServices/Makefile.kmk
@@ -21,7 +21,11 @@ include $(KBUILD_PATH)/subheader.kmk
# VBoxNetDHCP and VBoxNetNAT require COM/XPCOM
ifdef VBOX_WITH_MAIN
# Include sub-makefiles.
- include $(PATH_SUB_CURRENT)/DHCP/Makefile.kmk
+ ifndef VBOX_WITH_DHCPD
+ include $(PATH_SUB_CURRENT)/DHCP/Makefile.kmk
+ else
+ include $(PATH_SUB_CURRENT)/Dhcpd/Makefile.kmk
+ endif
ifdef VBOX_WITH_NAT_SERVICE
include $(PATH_SUB_CURRENT)/NAT/Makefile.kmk
endif