VirtualBox

Ignore:
Timestamp:
Feb 25, 2013 6:30:42 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83953
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/NetworkServices/NetLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.

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