Index: trunk/src/VBox/Devices/Makefile.kmk
===================================================================
--- trunk/src/VBox/Devices/Makefile.kmk	(revision 44823)
+++ trunk/src/VBox/Devices/Makefile.kmk	(revision 44824)
@@ -1063,5 +1063,6 @@
  #
  ServicesR0_TEMPLATE  = VBoxR0
- ServicesR0_DEFS      = IN_INTNET_R0 IN_RT_R0 $(if $(VBOX_WITH_PCI_PASSTHROUGH),IN_PCIRAW_R0,)
+ ServicesR0_DEFS      = IN_INTNET_R0 IN_RT_R0 $(if $(VBOX_WITH_PCI_PASSTHROUGH),IN_PCIRAW_R0,) \
+	$(if $(VBOX_WITH_NAT_SERVICE),VBOX_WITH_NAT_SERVICE,)
  ServicesR0_SOURCES   = \
  	Network/SrvIntNetR0.cpp \
Index: trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
===================================================================
--- trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp	(revision 44823)
+++ trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp	(revision 44824)
@@ -4997,4 +4997,11 @@
         case kIntNetTrunkType_None:
         case kIntNetTrunkType_WhateverNone:
+#ifdef VBOX_WITH_NAT_SERVICE
+	    /* 
+	     * Well, here we don't want load anything special,
+	     * just communicate between processes via internal network. 
+	     */
+	case kIntNetTrunkType_SrvNat:
+#endif
             return VINF_SUCCESS;
 
@@ -5016,7 +5023,9 @@
 #endif /* VBOXNETADP_DO_NOT_USE_NETFLT */
             break;
-        case kIntNetTrunkType_SrvNat:
-            pszName = "VBoxSrvNat";
+#ifndef VBOX_WITH_NAT_SERVICE   
+	case kIntNetTrunkType_SrvNat:
+	    pszName = "VBoxSrvNat";
             break;
+#endif
     }
 
@@ -5477,7 +5486,10 @@
              */
             int rc;
-            if (    enmTrunkType == kIntNetTrunkType_WhateverNone
-                ||  (   pCur->enmTrunkType == enmTrunkType
-                     && !strcmp(pCur->szTrunk, pszTrunk)))
+            if (   enmTrunkType == kIntNetTrunkType_WhateverNone
+#ifdef VBOX_WITH_NAT_SERVICE
+		|| enmTrunkType == kIntNetTrunkType_SrvNat /* @todo: what does it mean */
+#endif
+                || (   pCur->enmTrunkType == enmTrunkType
+		    && !strcmp(pCur->szTrunk, pszTrunk)))
             {
                 rc = intnetR0CheckOpenNetworkFlags(pCur, fFlags);
@@ -5575,4 +5587,7 @@
                        | INTNET_OPEN_FLAGS_TRUNK_WIRE_CHASTE_MODE;
     if (   enmTrunkType == kIntNetTrunkType_WhateverNone
+#ifdef VBOX_WITH_NAT_SERVICE
+	|| enmTrunkType == kIntNetTrunkType_SrvNat /* simialar security */
+#endif
         || enmTrunkType == kIntNetTrunkType_None)
         fDefFlags |= INTNET_OPEN_FLAGS_ACCESS_RESTRICTED;
@@ -5740,4 +5755,7 @@
         case kIntNetTrunkType_None:
         case kIntNetTrunkType_WhateverNone:
+#ifdef VBOX_WITH_NAT_SERVICE
+	case kIntNetTrunkType_SrvNat:
+#endif
             if (*pszTrunk)
                 return VERR_INVALID_PARAMETER;
Index: trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- trunk/src/VBox/Main/Makefile.kmk	(revision 44823)
+++ trunk/src/VBox/Main/Makefile.kmk	(revision 44824)
@@ -316,5 +316,4 @@
 	src-server/MediumImpl.cpp \
 	src-server/MediumLock.cpp \
-	$(if $(VBOX_WITH_NAT_SERVICE),src-server/NATServerImpl.cpp,) \
 	src-server/NATEngineImpl.cpp \
 	src-server/NetworkAdapterImpl.cpp \
Index: trunk/src/VBox/NetworkServices/NAT/Makefile.kmk
===================================================================
--- trunk/src/VBox/NetworkServices/NAT/Makefile.kmk	(revision 44823)
+++ trunk/src/VBox/NetworkServices/NAT/Makefile.kmk	(revision 44824)
@@ -17,11 +17,12 @@
 SUB_DEPTH = ../../../..
 include $(KBUILD_PATH)/subheader.kmk
-
-ifdef VBOX_WITH_HARDENING
- PROGRAMS += VBoxNetNATHardened
- DLLS += VBoxNetNAT
-else
- PROGRAMS += VBoxNetNAT
-endif
+#
+# Disable Slirp based service.
+#ifdef VBOX_WITH_HARDENING
+# PROGRAMS += VBoxNetNATHardened
+# DLLS += VBoxNetNAT
+#else
+# PROGRAMS += VBoxNetNAT
+#endif
 VBoxNetNAT_TEMPLATE =
 VBoxNetNAT_TEMPLATE := VBOXR3$(if-expr defined(VBOX_WITH_HARDENING),,EXE)
@@ -35,17 +36,25 @@
 #endef
 
-define def_vbox_slirp_service_sources
-    VBoxNetNAT_SOURCES += $1/$(file)
+define def_vbox_nat_network_service_sources
+    $(1)_SOURCES += $2/$3
 endef
+
+define def_vbox_nat_network_service_incs
+    $(1)_INCS += $2/$3
+endef
+
 VBOX_NOT_IN_NATSERVICE = Network/DrvNAT.cpp
-$(foreach file,$(filter-out $(VBOX_NOT_IN_NATSERVICE), $(VBOX_SLIRP_SOURCES)),$(eval $(call def_vbox_slirp_service_sources, ../../Devices)))
-$(foreach file,$(VBOX_SLIRP_ALIAS_SOURCES),$(eval $(call def_vbox_slirp_service_sources, ../../Devices)))
-$(foreach file,$(VBOX_SLIRP_BSD_SOURCES),$(eval $(call def_vbox_slirp_service_sources, ../../Devices)))
+$(foreach file,$(filter-out $(VBOX_NOT_IN_NATSERVICE), $(VBOX_SLIRP_SOURCES)),$(eval $(call def_vbox_nat_network_service_sources,VBoxNetNAT,../../Devices,$(file))))
+$(foreach file,$(VBOX_SLIRP_ALIAS_SOURCES),$(eval $(call def_vbox_nat_network_service_sources, VBoxNetNAT,../../Devices,$(file))))
+$(foreach file,$(VBOX_SLIRP_BSD_SOURCES),$(eval $(call def_vbox_nat_network_service_sources, VBoxNetNAT,../../Devices,$(file))))
 
-$(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_BSD_SOURCES)),$(eval $(call def_vbox_slirp_cflags, ../../Devices/Network)))
-$(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_BSD_SOURCES)),$(eval $(call def_vbox_slirp_bsd_cflags, ../../Devices/Network)))
+$(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_BSD_SOURCES)),$(eval $(call def_vbox_slirp_cflags,../../Devices/Network)))
+$(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_BSD_SOURCES)),$(eval $(call def_vbox_slirp_bsd_cflags,../../Devices/Network)))
 $(foreach file,$(addprefix ../../Devices/, $(filter-out $(VBOX_WITH_NAT_SERVICE), $(VBOX_SLIRP_SOURCES))),$(eval $(call def_vbox_slirp_service_cflags, ../../Devices/Network)))
-$(foreach file,$(addprefix ../../Devices/, $(filter-out $(VBOX_WITH_NAT_SERVICE), $(VBOX_SLIRP_SOURCES))),$(eval $(call def_vbox_slirp_cflags, ../../Devices/Network)))
+$(foreach file,$(addprefix ../../Devices/, $(filter-out $(VBOX_WITH_NAT_SERVICE), $(VBOX_SLIRP_SOURCES))),$(eval $(call def_vbox_slirp_cflags,../../Devices/Network)))
+
 $(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_ALIAS_SOURCES)),$(eval $(call def_vbox_slirp_cflags, ../../Devices/Network)))
+
+
 $(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_ALIAS_SOURCES)),$(eval $(call def_vbox_slirp_alias_cflags, ../../Devices/Network)))
 
@@ -56,3 +65,28 @@
 VBoxNetNAT_LDFLAGS.win = /SUBSYSTEM:windows
 
+ifdef VBOX_WITH_LWIP_NAT
+
+PROGRAMS += VBoxNetLwipNAT
+VBoxNetLwipNAT_TEMPLATE =
+VBoxNetLwipNAT_TEMPLATE := VBOXR3$(if-expr defined(VBOX_WITH_HARDENING),,EXE)
+#VBoxNetLwipNAT_INCS += ${LWIP_INCS}
+VBoxNetLwipNAT_INCS += ../../Devices/Network \
+	../../Devices/Network/lwip-new/vbox # testproxy.h
+VBoxNetLwipNAT_DEFS += ${LWIP_DEFS} 
+VBoxNetLwipNAT_SOURCES += VBoxNetLwipNAT.cpp	\
+	../NetLib/VBoxNetBaseService.cpp \
+	../../Devices/Network/VBoxLwipCore.cpp
+VBoxNetLwipNAT_LIBS = \
+	$(LIB_RUNTIME)
+VBoxNetLwipNAT_LDFLAGS.win = /SUBSYSTEM:windows
+
+#
+# Note: not spaces please in "Devices,$("
+#
+$(foreach file,$(LWIP_SOURCES),$(eval $(call def_vbox_nat_network_service_sources, VBoxNetLwipNAT, ../../Devices,$(file))))
+
+$(foreach incs,$(LWIP_INCS),$(eval $(call def_vbox_nat_network_service_incs, VBoxNetLwipNAT, ../../Devices,$(incs))))
+
+endif
+
 include $(FILE_KBUILD_SUB_FOOTER)
Index: trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
===================================================================
--- trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp	(revision 44823)
+++ trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp	(revision 44824)
@@ -37,4 +37,5 @@
 #include <VBox/sup.h>
 #include <VBox/intnet.h>
+#include <VBox/intnetinline.h>
 #include <VBox/vmm/vmm.h>
 #include <VBox/version.h>
@@ -69,4 +70,6 @@
 VBoxNetBaseService::VBoxNetBaseService()
 {
+  int rc = RTCritSectInit(&m_csThis);
+  AssertRC(rc);
 }
 VBoxNetBaseService::~VBoxNetBaseService()
@@ -92,4 +95,5 @@
         m_pSession = NIL_RTR0PTR;
     }
+    RTCritSectDelete(&m_csThis);
 }
 
@@ -97,6 +101,6 @@
 {
     /* numbers from DrvIntNet */
-    m_cbSendBuf             =  36 * _1K;
-    m_cbRecvBuf             = 218 * _1K;
+    m_cbSendBuf             = 128 * _1K;
+    m_cbRecvBuf             = 256 * _1K;
     m_hIf                   = INTNET_HANDLE_INVALID;
     m_pIfBuf                = NULL;
@@ -124,4 +128,8 @@
     int rc = RTGetOptInit(&State, argc, argv, paOptionArray, m_vecOptionDefs.size(), 0, 0 /*fFlags*/);
     AssertRCReturn(rc, 49);
+#if 0
+    /* default initialization */
+    m_enmTrunkType = kIntNetTrunkType_WhateverNone;
+#endif
     Log2(("BaseService: parseArgs enter\n"));
 
@@ -309,4 +317,60 @@
 }
 
+int VBoxNetBaseService::waitForIntNetEvent(int cMillis)
+{
+    int rc = VINF_SUCCESS;
+    INTNETIFWAITREQ WaitReq;
+    LogFlowFunc(("ENTER:cMillis: %d\n", cMillis));
+    WaitReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
+    WaitReq.Hdr.cbReq = sizeof(WaitReq);
+    WaitReq.pSession = m_pSession;
+    WaitReq.hIf = m_hIf;
+    WaitReq.cMillies = cMillis;
+
+    rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_WAIT, 0, &WaitReq.Hdr);
+    LogFlowFuncLeaveRC(rc);
+    return rc;
+}
+
+/* S/G API */
+int VBoxNetBaseService::sendBufferOnWire(PCINTNETSEG pcSg, int cSg, size_t cbFrame)
+{
+    int rc = VINF_SUCCESS;
+    PINTNETHDR pHdr = NULL;
+    uint8_t *pu8Frame = NULL;
+    int offFrame = 0;
+    int idxSg = 0;
+    /* Allocate frame */
+    rc = IntNetRingAllocateFrame(&m_pIfBuf->Send, cbFrame, &pHdr, (void **)&pu8Frame);
+    AssertRCReturn(rc, rc);
+    /* Now we fill pvFrame with S/G above */
+    for (idxSg = 0; idxSg < cSg; ++idxSg)
+    {
+	memcpy(&pu8Frame[offFrame], pcSg[idxSg].pv, pcSg[idxSg].cb);
+	offFrame+=pcSg[idxSg].cb;
+    }
+    /* Commit */
+    IntNetRingCommitFrame(&m_pIfBuf->Send, pHdr);
+   
+    LogFlowFuncLeaveRC(rc);
+    return rc;
+}
+/**
+ * forcible ask for send packet on the "wire"
+ */
+void VBoxNetBaseService::flushWire()
+{
+    int rc = VINF_SUCCESS;
+    INTNETIFSENDREQ SendReq;
+    SendReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
+    SendReq.Hdr.cbReq    = sizeof(SendReq);
+    SendReq.pSession     = m_pSession;
+    SendReq.hIf          = m_hIf;
+    rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_SEND, 0, &SendReq.Hdr);
+    AssertRCReturnVoid(rc);
+    LogFlowFuncLeave();
+
+}
+
 /**
  * Print debug message depending on the m_cVerbosity level.
Index: trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
===================================================================
--- trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h	(revision 44823)
+++ trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h	(revision 44824)
@@ -18,4 +18,5 @@
 #ifndef ___VBoxNetBaseService_h___
 #define ___VBoxNetBaseService_h___
+#include <iprt/critsect.h>
 class VBoxNetBaseService
 {
@@ -26,4 +27,9 @@
     int                 tryGoOnline(void);
     void                shutdown(void);
+    int                 syncEnter() { return RTCritSectEnter(&this->m_csThis);}
+    int                 syncLeave() { return RTCritSectLeave(&this->m_csThis);}
+    int                 waitForIntNetEvent(int cMillis);
+    int                 sendBufferOnWire(PCINTNETSEG pSg, int cSg, size_t cbBuffer);
+    void                flushWire();
     virtual void        usage(void) = 0;
     virtual void        run(void) = 0;
@@ -42,4 +48,6 @@
     RTMAC               m_MacAddress;
     RTNETADDRIPV4       m_Ipv4Address;
+    /* cs for syncing */
+    RTCRITSECT          m_csThis;
     /** @} */
     /** @name The network interface
