VBoxNetDHCP.cpp revision 1af704e0ccef76a9d375efc06d2a5eba6d679809
59190ecd61435d19ba3515b876272aee7bd12298vboxsync * VBoxNetDHCP - DHCP Service for connecting to IntNet.
772269936494ffaddd0750ba9e28e805ba81398cvboxsync * Copyright (C) 2009-2011 Oracle Corporation
c55c68b6a3324172e9dc207926215845880b0f90vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c55c68b6a3324172e9dc207926215845880b0f90vboxsync * available from http://www.virtualbox.org. This file is free software;
c55c68b6a3324172e9dc207926215845880b0f90vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c55c68b6a3324172e9dc207926215845880b0f90vboxsync * General Public License (GPL) as published by the Free Software
c55c68b6a3324172e9dc207926215845880b0f90vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c55c68b6a3324172e9dc207926215845880b0f90vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c55c68b6a3324172e9dc207926215845880b0f90vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
59190ecd61435d19ba3515b876272aee7bd12298vboxsync/** @page pg_net_dhcp VBoxNetDHCP
59190ecd61435d19ba3515b876272aee7bd12298vboxsync * Write a few words...
59190ecd61435d19ba3515b876272aee7bd12298vboxsync/*******************************************************************************
59190ecd61435d19ba3515b876272aee7bd12298vboxsync* Header Files *
59190ecd61435d19ba3515b876272aee7bd12298vboxsync*******************************************************************************/
59190ecd61435d19ba3515b876272aee7bd12298vboxsync/*******************************************************************************
772269936494ffaddd0750ba9e28e805ba81398cvboxsync* Structures and Typedefs *
59190ecd61435d19ba3515b876272aee7bd12298vboxsync*******************************************************************************/
VBoxNetDhcp();
virtual ~VBoxNetDhcp();
int init();
int run(void);
char Key;
} CMDLNPRM;
RTTimeSpecAddSeconds(&m_ExpireTime, m_pCfg ? m_pCfg->m_cSecLease : 60); /* m_pCfg can be NULL right now... */
activate();
m_cVerbosity = 0;
m_cbCurMsg = 0;
m_fIgnoreCmdLineParameters = true;
m_fIgnoreCmdLineParameters = false;
switch (rc)
return rc;
return rc;
&& fNeedDhcpServer)
int idx = 0;
idx++;
return VINF_SUCCESS;
WaitReq.cMillies = 2000; /* 2 secs - the sleep is for some reason uninterruptible... */ /** @todo fix interruptability in SrvIntNet! */
debugPrint(1, true, "VBoxNetDHCP: Skipping invalid DHCP packet.\n"); /** @todo handle pure bootp clients too? */
m_cbCurMsg = 0;
switch (uMsgType)
case RTNET_DHCP_MT_DISCOVER:
case RTNET_DHCP_MT_REQUEST:
case RTNET_DHCP_MT_DECLINE:
case RTNET_DHCP_MT_RELEASE:
case RTNET_DHCP_MT_INFORM:
return VINF_SUCCESS;
RTStrmPrintf(g_pStdErr, "VBoxNetDHCP: %s: %N\n", iMinLevel >= 2 ? "debug" : "info", pszFmt, &vaCopy);
if ( fMsg
&& m_pCurMsg)
RTStrmPrintf(g_pStdErr, "VBoxNetDHCP: debug: %8s chaddr=%.6Rhxs ciaddr=%d.%d.%d.%d yiaddr=%d.%d.%d.%d siaddr=%d.%d.%d.%d xid=%#x\n",
m_pCurMsg->bp_ciaddr.au8[0], m_pCurMsg->bp_ciaddr.au8[1], m_pCurMsg->bp_ciaddr.au8[2], m_pCurMsg->bp_ciaddr.au8[3],
m_pCurMsg->bp_yiaddr.au8[0], m_pCurMsg->bp_yiaddr.au8[1], m_pCurMsg->bp_yiaddr.au8[2], m_pCurMsg->bp_yiaddr.au8[3],
m_pCurMsg->bp_siaddr.au8[0], m_pCurMsg->bp_siaddr.au8[1], m_pCurMsg->bp_siaddr.au8[2], m_pCurMsg->bp_siaddr.au8[3],
switch (uMsgType)
if (!pDhcp)
if (rc)
return rc;
if (rc)
delete pDhcp;
return rc;
delete pDhcp;
return rc;
#ifndef VBOX_WITH_HARDENING
# ifdef RT_OS_WINDOWS
PostQuitMessage(0);
bool bExit = false;
if (atomWindowClass != 0)
if (hwnd)
bExit = true;
if(bExit)
/* no need any accuracy here, in anyway the DHCP server usually gets terminated with TerminateProcess */
exit(0);