VBoxNetLwipNAT.cpp revision 778f17dea66e4e9cd14f3afba4a0853d0aef8804
bf5156a896cd0169ffb3a1fd145c114ddab0538cDav Glass * VBoxNetNAT - NAT Service for connecting to IntNet.
bf5156a896cd0169ffb3a1fd145c114ddab0538cDav Glass * Copyright (C) 2009 Oracle Corporation
bf5156a896cd0169ffb3a1fd145c114ddab0538cDav Glass * This file is part of VirtualBox Open Source Edition (OSE), as
bf5156a896cd0169ffb3a1fd145c114ddab0538cDav Glass * available from http://www.virtualbox.org. This file is free software;
bf5156a896cd0169ffb3a1fd145c114ddab0538cDav Glass * you can redistribute it and/or modify it under the terms of the GNU
#include "winutils.h"
#ifndef RT_OS_WINDOWS
#ifndef RT_OS_WINDOWS
#include <vector>
#include <string>
#include "../NetLib/VBoxNetLib.h"
#include "../NetLib/VBoxNetBaseService.h"
#include "VBoxLwipCore.h"
#ifdef LWIP_SOCKET
# define LWIP_SOCKET 0
#include "lwip/tcp_impl.h"
#include "proxytest.h"
#include "pxremap.h"
#include "portfwd.h"
#include "../NetLib/VBoxPortForwardString.h"
typedef struct NATSEVICEPORTFORWARDRULE
class PortForwardListener;
friend class PortForwardListener;
virtual ~VBoxNetLwipNAT();
int run();
virtual int init(void);
bool fDontLoadRulesOnStartup;
static void vboxNetLwipNATProcessXmit(void);
class PortForwardListener
return S_OK;
return S_OK;
if (m_pNAT)
return E_FAIL;
switch (aEventType)
RT_ZERO(r);
goto port_forward_done;
switch (proto)
case NATProtocol_TCP:
case NATProtocol_UDP:
goto port_forward_done;
if (!pFwCopy)
return hrc;
return rcLwip;
switch (u8Type)
case INTNETHDR_TYPE_FRAME:
if (!pPbuf)
while(pPbuf)
case INTNETHDR_TYPE_GSO:
cbFrame);
void *pvSegFrame =
iSeg,
&cbSegFrame);
if (!pPbuf)
case INTNETHDR_TYPE_PADDING:
return rc;
pPBuf));
int offFrame = 0;
int idxSg = 0;
rc = IntNetRingAllocateFrame(&g_pLwipNat->m_pIfBuf->Send, pPBuf->tot_len, &pHdr, (void **)&pu8Frame);
while (pPBufPtr)
return rcLwip;
#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;
#if !defined(RT_OS_WINDOWS)
if (!fDontLoadRulesOnStartup)
int count_strs;
char *pszTerm;
if ( !pszTerm
if (u32Off == 0)
return rc;
switch (rc)
fDontLoadRulesOnStartup = true;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
return VINF_SUCCESS;
#ifdef RT_OS_WINDOWS
int err;
if (err)
#ifdef VBOX_WITH_XPCOM
if (!rc)
delete g_pLwipNat;
#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);