VBoxNetLwipNAT.cpp revision 5eb4b75eda15627221295b5a3edf2d0622b4da28
1N/A * available from http://www.virtualbox.org. This file is free software;
1N/A#include "winutils.h"
1N/A#ifndef RT_OS_WINDOWS
1N/A#ifndef RT_OS_WINDOWS
1N/A# ifdef RT_OS_LINUX
1N/A#include "../NetLib/VBoxNetLib.h"
1N/A#include "../NetLib/VBoxNetBaseService.h"
1N/A#include "VBoxLwipCore.h"
1N/A#ifdef LWIP_SOCKET
1N/A# define LWIP_SOCKET 0
1N/A#if defined(VBOX_RAWSOCK_DEBUG_HELPER) \
1N/A && (defined(VBOX_WITH_HARDENING) \
1N/A || defined(RT_OS_WINDOWS) \
1N/A || defined(RT_OS_DARWIN))
1N/A#include "../NetLib/VBoxPortForwardString.h"
1N/Atypedef struct NATSEVICEPORTFORWARDRULE
1N/A friend class NATNetworkListener;
1N/A virtual ~VBoxNetLwipNAT();
1N/A virtual bool isMainNeeded() const { return true; }
1N/A const char **getHostNameservers();
1N/A bool fDontLoadRulesOnStartup;
1N/A switch (aEventType)
1N/A goto port_forward_done;
1N/A case NATProtocol_TCP:
1N/A case NATProtocol_UDP:
1N/A goto port_forward_done;
return rcLwip;
pPBuf));
unsigned idx = 0;
return ERR_OK;
VBoxNetLwipNAT::VBoxNetLwipNAT(SOCKET icmpsock4, SOCKET icmpsock6) : VBoxNetBaseService("VBoxNetNAT", "nat-network")
#if HAVE_SA_LEN
fDontLoadRulesOnStartup = false;
int lrc = 0;
char *pszHostAddr;
case IPPROTO_TCP:
case IPPROTO_UDP:
&& pszHostAddr[0] == 0)
return VINF_SUCCESS;
return VINF_SUCCESS;
/** This method executed on main thread, only at the end threr're one threads started explcitly (LWIP and later in ::run()
if (fIPv6Enabled)
if (!fDontLoadRulesOnStartup)
++it, ++i)
return rc;
return rc;
return NULL;
return NULL;
if (cNameServers == 0)
return NULL;
const char **ppcszNameServers =
return NULL;
++idxLast;
if (idxLast == 0)
return NULL;
return ppcszNameServers;
switch (rc)
fDontLoadRulesOnStartup = true;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
AssertMsgReturn(pPbuf, ("NAT: Can't allocate send buffer cbFrame=%u\n", cbFrame), VERR_INTERNAL_ERROR);
while(pPbuf)
return VINF_SUCCESS;
return VERR_INVALID_PARAMETER;
cbFrame);
void *pvSegFrame =
iSeg,
&cbSegFrame);
AssertMsgReturn(pPbuf, ("NAT: Can't allocate send buffer cbFrame=%u\n", cbSegFrame), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
return VINF_SUCCESS;
#ifdef RT_OS_WINDOWS
int err;
if (err)
#ifndef RT_OS_DARWIN
#ifdef VBOX_RAWSOCK_DEBUG_HELPER
~(uint32_t)(
if (status < 0)
#ifdef VBOX_RAWSOCK_DEBUG_HELPER
* XXX: We do this here for now, not in pxping.c, to avoid
if (status < 0)
#ifdef VBOX_WITH_XPCOM
delete g_pLwipNat;
if (fIsIPv6)
return VINF_SUCCESS;
#ifndef VBOX_WITH_HARDENING
# if defined(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);