VirtualBox

Changeset 44824 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 25, 2013 6:30:42 PM (12 years ago)
Author:
vboxsync
Message:

Network-service for lwip-driven proxy.
additionally enables SrvNat trunk type for Nat services.
Note: all changes disabled by default.

Location:
trunk/src/VBox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Makefile.kmk

    r44807 r44824  
    10631063 #
    10641064 ServicesR0_TEMPLATE  = VBoxR0
    1065  ServicesR0_DEFS      = IN_INTNET_R0 IN_RT_R0 $(if $(VBOX_WITH_PCI_PASSTHROUGH),IN_PCIRAW_R0,)
     1065 ServicesR0_DEFS      = IN_INTNET_R0 IN_RT_R0 $(if $(VBOX_WITH_PCI_PASSTHROUGH),IN_PCIRAW_R0,) \
     1066        $(if $(VBOX_WITH_NAT_SERVICE),VBOX_WITH_NAT_SERVICE,)
    10661067 ServicesR0_SOURCES   = \
    10671068        Network/SrvIntNetR0.cpp \
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r44528 r44824  
    49974997        case kIntNetTrunkType_None:
    49984998        case kIntNetTrunkType_WhateverNone:
     4999#ifdef VBOX_WITH_NAT_SERVICE
     5000            /*
     5001             * Well, here we don't want load anything special,
     5002             * just communicate between processes via internal network.
     5003             */
     5004        case kIntNetTrunkType_SrvNat:
     5005#endif
    49995006            return VINF_SUCCESS;
    50005007
     
    50165023#endif /* VBOXNETADP_DO_NOT_USE_NETFLT */
    50175024            break;
    5018         case kIntNetTrunkType_SrvNat:
    5019             pszName = "VBoxSrvNat";
     5025#ifndef VBOX_WITH_NAT_SERVICE   
     5026        case kIntNetTrunkType_SrvNat:
     5027            pszName = "VBoxSrvNat";
    50205028            break;
     5029#endif
    50215030    }
    50225031
     
    54775486             */
    54785487            int rc;
    5479             if (    enmTrunkType == kIntNetTrunkType_WhateverNone
    5480                 ||  (   pCur->enmTrunkType == enmTrunkType
    5481                      && !strcmp(pCur->szTrunk, pszTrunk)))
     5488            if (   enmTrunkType == kIntNetTrunkType_WhateverNone
     5489#ifdef VBOX_WITH_NAT_SERVICE
     5490                || enmTrunkType == kIntNetTrunkType_SrvNat /* @todo: what does it mean */
     5491#endif
     5492                || (   pCur->enmTrunkType == enmTrunkType
     5493                    && !strcmp(pCur->szTrunk, pszTrunk)))
    54825494            {
    54835495                rc = intnetR0CheckOpenNetworkFlags(pCur, fFlags);
     
    55755587                       | INTNET_OPEN_FLAGS_TRUNK_WIRE_CHASTE_MODE;
    55765588    if (   enmTrunkType == kIntNetTrunkType_WhateverNone
     5589#ifdef VBOX_WITH_NAT_SERVICE
     5590        || enmTrunkType == kIntNetTrunkType_SrvNat /* simialar security */
     5591#endif
    55775592        || enmTrunkType == kIntNetTrunkType_None)
    55785593        fDefFlags |= INTNET_OPEN_FLAGS_ACCESS_RESTRICTED;
     
    57405755        case kIntNetTrunkType_None:
    57415756        case kIntNetTrunkType_WhateverNone:
     5757#ifdef VBOX_WITH_NAT_SERVICE
     5758        case kIntNetTrunkType_SrvNat:
     5759#endif
    57425760            if (*pszTrunk)
    57435761                return VERR_INVALID_PARAMETER;
  • trunk/src/VBox/Main/Makefile.kmk

    r44528 r44824  
    316316        src-server/MediumImpl.cpp \
    317317        src-server/MediumLock.cpp \
    318         $(if $(VBOX_WITH_NAT_SERVICE),src-server/NATServerImpl.cpp,) \
    319318        src-server/NATEngineImpl.cpp \
    320319        src-server/NetworkAdapterImpl.cpp \
  • trunk/src/VBox/NetworkServices/NAT/Makefile.kmk

    r41477 r44824  
    1717SUB_DEPTH = ../../../..
    1818include $(KBUILD_PATH)/subheader.kmk
    19 
    20 ifdef VBOX_WITH_HARDENING
    21  PROGRAMS += VBoxNetNATHardened
    22  DLLS += VBoxNetNAT
    23 else
    24  PROGRAMS += VBoxNetNAT
    25 endif
     19#
     20# Disable Slirp based service.
     21#ifdef VBOX_WITH_HARDENING
     22# PROGRAMS += VBoxNetNATHardened
     23# DLLS += VBoxNetNAT
     24#else
     25# PROGRAMS += VBoxNetNAT
     26#endif
    2627VBoxNetNAT_TEMPLATE =
    2728VBoxNetNAT_TEMPLATE := VBOXR3$(if-expr defined(VBOX_WITH_HARDENING),,EXE)
     
    3536#endef
    3637
    37 define def_vbox_slirp_service_sources
    38     VBoxNetNAT_SOURCES += $1/$(file)
     38define def_vbox_nat_network_service_sources
     39    $(1)_SOURCES += $2/$3
    3940endef
     41
     42define def_vbox_nat_network_service_incs
     43    $(1)_INCS += $2/$3
     44endef
     45
    4046VBOX_NOT_IN_NATSERVICE = Network/DrvNAT.cpp
    41 $(foreach file,$(filter-out $(VBOX_NOT_IN_NATSERVICE), $(VBOX_SLIRP_SOURCES)),$(eval $(call def_vbox_slirp_service_sources, ../../Devices)))
    42 $(foreach file,$(VBOX_SLIRP_ALIAS_SOURCES),$(eval $(call def_vbox_slirp_service_sources, ../../Devices)))
    43 $(foreach file,$(VBOX_SLIRP_BSD_SOURCES),$(eval $(call def_vbox_slirp_service_sources, ../../Devices)))
     47$(foreach file,$(filter-out $(VBOX_NOT_IN_NATSERVICE), $(VBOX_SLIRP_SOURCES)),$(eval $(call def_vbox_nat_network_service_sources,VBoxNetNAT,../../Devices,$(file))))
     48$(foreach file,$(VBOX_SLIRP_ALIAS_SOURCES),$(eval $(call def_vbox_nat_network_service_sources, VBoxNetNAT,../../Devices,$(file))))
     49$(foreach file,$(VBOX_SLIRP_BSD_SOURCES),$(eval $(call def_vbox_nat_network_service_sources, VBoxNetNAT,../../Devices,$(file))))
    4450
    45 $(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_BSD_SOURCES)),$(eval $(call def_vbox_slirp_cflags, ../../Devices/Network)))
    46 $(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_BSD_SOURCES)),$(eval $(call def_vbox_slirp_bsd_cflags, ../../Devices/Network)))
     51$(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_BSD_SOURCES)),$(eval $(call def_vbox_slirp_cflags,../../Devices/Network)))
     52$(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_BSD_SOURCES)),$(eval $(call def_vbox_slirp_bsd_cflags,../../Devices/Network)))
    4753$(foreach file,$(addprefix ../../Devices/, $(filter-out $(VBOX_WITH_NAT_SERVICE), $(VBOX_SLIRP_SOURCES))),$(eval $(call def_vbox_slirp_service_cflags, ../../Devices/Network)))
    48 $(foreach file,$(addprefix ../../Devices/, $(filter-out $(VBOX_WITH_NAT_SERVICE), $(VBOX_SLIRP_SOURCES))),$(eval $(call def_vbox_slirp_cflags, ../../Devices/Network)))
     54$(foreach file,$(addprefix ../../Devices/, $(filter-out $(VBOX_WITH_NAT_SERVICE), $(VBOX_SLIRP_SOURCES))),$(eval $(call def_vbox_slirp_cflags,../../Devices/Network)))
     55
    4956$(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_ALIAS_SOURCES)),$(eval $(call def_vbox_slirp_cflags, ../../Devices/Network)))
     57
     58
    5059$(foreach file,$(addprefix ../../Devices/, $(VBOX_SLIRP_ALIAS_SOURCES)),$(eval $(call def_vbox_slirp_alias_cflags, ../../Devices/Network)))
    5160
     
    5665VBoxNetNAT_LDFLAGS.win = /SUBSYSTEM:windows
    5766
     67ifdef VBOX_WITH_LWIP_NAT
     68
     69PROGRAMS += VBoxNetLwipNAT
     70VBoxNetLwipNAT_TEMPLATE =
     71VBoxNetLwipNAT_TEMPLATE := VBOXR3$(if-expr defined(VBOX_WITH_HARDENING),,EXE)
     72#VBoxNetLwipNAT_INCS += ${LWIP_INCS}
     73VBoxNetLwipNAT_INCS += ../../Devices/Network \
     74        ../../Devices/Network/lwip-new/vbox # testproxy.h
     75VBoxNetLwipNAT_DEFS += ${LWIP_DEFS}
     76VBoxNetLwipNAT_SOURCES += VBoxNetLwipNAT.cpp    \
     77        ../NetLib/VBoxNetBaseService.cpp \
     78        ../../Devices/Network/VBoxLwipCore.cpp
     79VBoxNetLwipNAT_LIBS = \
     80        $(LIB_RUNTIME)
     81VBoxNetLwipNAT_LDFLAGS.win = /SUBSYSTEM:windows
     82
     83#
     84# Note: not spaces please in "Devices,$("
     85#
     86$(foreach file,$(LWIP_SOURCES),$(eval $(call def_vbox_nat_network_service_sources, VBoxNetLwipNAT, ../../Devices,$(file))))
     87
     88$(foreach incs,$(LWIP_INCS),$(eval $(call def_vbox_nat_network_service_incs, VBoxNetLwipNAT, ../../Devices,$(incs))))
     89
     90endif
     91
    5892include $(FILE_KBUILD_SUB_FOOTER)
  • trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp

    r39685 r44824  
    3737#include <VBox/sup.h>
    3838#include <VBox/intnet.h>
     39#include <VBox/intnetinline.h>
    3940#include <VBox/vmm/vmm.h>
    4041#include <VBox/version.h>
     
    6970VBoxNetBaseService::VBoxNetBaseService()
    7071{
     72  int rc = RTCritSectInit(&m_csThis);
     73  AssertRC(rc);
    7174}
    7275VBoxNetBaseService::~VBoxNetBaseService()
     
    9295        m_pSession = NIL_RTR0PTR;
    9396    }
     97    RTCritSectDelete(&m_csThis);
    9498}
    9599
     
    97101{
    98102    /* numbers from DrvIntNet */
    99     m_cbSendBuf             =  36 * _1K;
    100     m_cbRecvBuf             = 218 * _1K;
     103    m_cbSendBuf             = 128 * _1K;
     104    m_cbRecvBuf             = 256 * _1K;
    101105    m_hIf                   = INTNET_HANDLE_INVALID;
    102106    m_pIfBuf                = NULL;
     
    124128    int rc = RTGetOptInit(&State, argc, argv, paOptionArray, m_vecOptionDefs.size(), 0, 0 /*fFlags*/);
    125129    AssertRCReturn(rc, 49);
     130#if 0
     131    /* default initialization */
     132    m_enmTrunkType = kIntNetTrunkType_WhateverNone;
     133#endif
    126134    Log2(("BaseService: parseArgs enter\n"));
    127135
     
    309317}
    310318
     319int VBoxNetBaseService::waitForIntNetEvent(int cMillis)
     320{
     321    int rc = VINF_SUCCESS;
     322    INTNETIFWAITREQ WaitReq;
     323    LogFlowFunc(("ENTER:cMillis: %d\n", cMillis));
     324    WaitReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
     325    WaitReq.Hdr.cbReq = sizeof(WaitReq);
     326    WaitReq.pSession = m_pSession;
     327    WaitReq.hIf = m_hIf;
     328    WaitReq.cMillies = cMillis;
     329
     330    rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_WAIT, 0, &WaitReq.Hdr);
     331    LogFlowFuncLeaveRC(rc);
     332    return rc;
     333}
     334
     335/* S/G API */
     336int VBoxNetBaseService::sendBufferOnWire(PCINTNETSEG pcSg, int cSg, size_t cbFrame)
     337{
     338    int rc = VINF_SUCCESS;
     339    PINTNETHDR pHdr = NULL;
     340    uint8_t *pu8Frame = NULL;
     341    int offFrame = 0;
     342    int idxSg = 0;
     343    /* Allocate frame */
     344    rc = IntNetRingAllocateFrame(&m_pIfBuf->Send, cbFrame, &pHdr, (void **)&pu8Frame);
     345    AssertRCReturn(rc, rc);
     346    /* Now we fill pvFrame with S/G above */
     347    for (idxSg = 0; idxSg < cSg; ++idxSg)
     348    {
     349        memcpy(&pu8Frame[offFrame], pcSg[idxSg].pv, pcSg[idxSg].cb);
     350        offFrame+=pcSg[idxSg].cb;
     351    }
     352    /* Commit */
     353    IntNetRingCommitFrame(&m_pIfBuf->Send, pHdr);
     354   
     355    LogFlowFuncLeaveRC(rc);
     356    return rc;
     357}
     358/**
     359 * forcible ask for send packet on the "wire"
     360 */
     361void VBoxNetBaseService::flushWire()
     362{
     363    int rc = VINF_SUCCESS;
     364    INTNETIFSENDREQ SendReq;
     365    SendReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
     366    SendReq.Hdr.cbReq    = sizeof(SendReq);
     367    SendReq.pSession     = m_pSession;
     368    SendReq.hIf          = m_hIf;
     369    rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_SEND, 0, &SendReq.Hdr);
     370    AssertRCReturnVoid(rc);
     371    LogFlowFuncLeave();
     372
     373}
     374
    311375/**
    312376 * Print debug message depending on the m_cVerbosity level.
  • trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h

    r44529 r44824  
    1818#ifndef ___VBoxNetBaseService_h___
    1919#define ___VBoxNetBaseService_h___
     20#include <iprt/critsect.h>
    2021class VBoxNetBaseService
    2122{
     
    2627    int                 tryGoOnline(void);
    2728    void                shutdown(void);
     29    int                 syncEnter() { return RTCritSectEnter(&this->m_csThis);}
     30    int                 syncLeave() { return RTCritSectLeave(&this->m_csThis);}
     31    int                 waitForIntNetEvent(int cMillis);
     32    int                 sendBufferOnWire(PCINTNETSEG pSg, int cSg, size_t cbBuffer);
     33    void                flushWire();
    2834    virtual void        usage(void) = 0;
    2935    virtual void        run(void) = 0;
     
    4248    RTMAC               m_MacAddress;
    4349    RTNETADDRIPV4       m_Ipv4Address;
     50    /* cs for syncing */
     51    RTCRITSECT          m_csThis;
    4452    /** @} */
    4553    /** @name The network interface
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette