VirtualBox

Changeset 10031

Show
Ignore:
Timestamp:
06/30/08 19:00:39 (6 months ago)
Author:
vboxsync
Message:

VBoxNetFlt - work in progress.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/intnet.h

    r9803 r10031  
    362362    DECLR0CALLBACKMEMBER(bool, pfnRecvWire,(PINTNETTRUNKSWPORT pIfPort, PINTNETSG pSG)); 
    363363 
     364    /** 
     365     * This is called by the pfnSendToHost and pfnSendToWire code when they are 
     366     * done with a SG. 
     367     * 
     368     * It may be called after they return if the frame was pushed in an 
     369     * async manner. 
     370     * 
     371     * @param   pIfPort     Pointer to this structure. 
     372     * @param   pSG         Pointer to the (scatter /) gather structure. 
     373     * 
     374     * @remarks Will grab the network semaphore. 
     375     */ 
     376    DECLR0CALLBACKMEMBER(void, pfnSGRelease,(PINTNETTRUNKIFPORT pIfPort, PINTNETSG pSG)); 
     377 
    364378    /** Structure version number. (INTNETTRUNKSWPORT_VERSION) */ 
    365379    uint32_t u32VersionEnd; 
     
    389403     * 
    390404     * @param   pIfPort     Pointer to this structure. 
     405     * 
     406     * @remarks The caller may own any locks. 
    391407     */ 
    392408    DECLR0CALLBACKMEMBER(void, pfnRetain,(PINTNETTRUNKIFPORT pIfPort)); 
     
    395411     * Releases the object. 
    396412     * 
    397      * This must be called for every pfnRetain call. Where possible, it 
    398      * should be executed without holding any locks unless the caller 
    399      * is certain it is not going to trigger the destructor. 
    400      * 
    401      * @param   pIfPort     Pointer to this structure. 
     413     * This must be called for every pfnRetain call. 
     414     * 
     415     * 
     416     * @param   pIfPort     Pointer to this structure. 
     417     * 
     418     * @remarks Where possible, it should be executed without holding any locks 
     419     *          unless the caller is certain it is not going to trigger the destructor. 
    402420     */ 
    403421    DECLR0CALLBACKMEMBER(void, pfnRelease,(PINTNETTRUNKIFPORT pIfPort)); 
     
    410428     * 
    411429     * @param   pIfPort     Pointer to this structure. 
     430     * 
     431     * @remarks Called without holding any locks. 
    412432     */ 
    413433    DECLR0CALLBACKMEMBER(void, pfnDisconnectAndRelease,(PINTNETTRUNKIFPORT pIfPort)); 
     
    421441     * the interface from the internal network, however, this might be done immediately 
    422442     * before disconnecting and may leave an incoming frame waiting on the internal network 
    423      * semaphore. 
     443     * semaphore. So, after the final suspend a pfnWaitForIdle is always called to make sure 
     444     * the interface is idle before pfnDisconnectAndRelease is called. 
    424445     * 
    425446     * @returns The previous state. 
     
    444465     *                      an indefinite wait. 
    445466     * 
    446      * @remarks Will not grab any semaphores
     467     * @remarks Called while *not* owning any semaphores. Will not grab anything
    447468     */ 
    448469    DECLR0CALLBACKMEMBER(bool, pfnWaitForIdle,(PINTNETTRUNKIFPORT pIfPort, uint32_t cMillies)); 
     
    467488     * Tests whether the host is operating the interface is promiscuous mode. 
    468489     * 
    469      * The default behavior of internal networking 'switch' is to 'autodetect' 
    470      * promiscuous mode on the trunk port, which is where this method is used. 
    471      * For security reasons this default my of course be overridden so that the 
     490     * The default behavior of the internal networking 'switch' is to 'autodetect' 
     491     * promiscuous mode on the trunk port, which is when this method is used. 
     492     * For security reasons this default may of course be overridden so that the 
    472493     * host cannot sniff at what's going on. 
    473494     * 
     
    498519     *                      allocating and copying. 
    499520     * 
    500      * @remarks Called while owning the network semaphore? 
     521     * @remarks Called while owning the network semaphore. 
     522     *          (Works on darwin, but may have to be relaxed later on other hosts.) 
    501523     * 
    502524     * @remarks TAP and NAT will use this interface for all their traffic, see pfnIsHostMac. 
     
    519541     *                      allocating and copying. 
    520542     * 
    521      * @remarks Called while owning the network semaphore? 
     543     * @remarks Called while owning the network semaphore. 
     544     *          (Works on darwin, but may have to be relaxed later on other hosts.) 
    522545     * 
    523546     * @remarks TAP and NAT will call pfnSGRelease and return successfully. 
    524547     */ 
    525548    DECLR0CALLBACKMEMBER(int, pfnSendToWire,(PINTNETTRUNKIFPORT pIfPort, PINTNETSG pSG)); 
    526  
    527     /** 
    528      * This is called by the pfnSendToHost and pfnSendToWire code when they are 
    529      * done with a SG. 
    530      * 
    531      * It may be called after they return if the frame was pushed in an 
    532      * async manner. 
    533      * 
    534      * @param   pIfPort     Pointer to this structure. 
    535      * @param   pSG         Pointer to the (scatter /) gather structure. 
    536      * 
    537      * @remarks Will grab the network semaphore. 
    538      */ 
    539     DECLR0CALLBACKMEMBER(void, pfnSGRelease,(PINTNETTRUNKIFPORT pIfPort, PINTNETSG pSG)); 
    540549 
    541550    /** Structure version number. (INTNETTRUNKIFPORT_VERSION) */ 
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r9694 r10031  
    8282    /** The SUPR0 object id. */ 
    8383    void                   *pvObj; 
    84 } INTNETIF, *PINTNETIF; 
     84} INTNETIF; 
     85typedef INTNETIF *PINTNETIF; 
    8586 
    8687 
     
    108109    /** The network name. */ 
    109110    char                    szName[INTNET_MAX_NETWORK_NAME]; 
    110 } INTNETNETWORK, *PINTNETNETWORK; 
     111} INTNETNETWORK; 
     112typedef INTNETNETWORK *PINTNETNETWORK; 
    111113 
    112114 
     
    117119{ 
    118120    /** Pointer to the object we're a handle for. */ 
    119     PINTNETIF       pIF; 
     121    PINTNETIF               pIF; 
    120122    /** Index to the next free entry. */ 
    121     uintptr_t       iNext; 
    122 } INTNETHTE, *PINTNETHTE; 
     123    uintptr_t               iNext; 
     124} INTNETHTE; 
     125typedef INTNETHTE *PINTNETHTE; 
    123126 
    124127 
     
    129132{ 
    130133    /** Pointer to the handle table. */ 
    131     PINTNETHTE          paEntries; 
     134    PINTNETHTE              paEntries; 
    132135    /** The number of allocated handles. */ 
    133     uint32_t            cAllocated; 
     136    uint32_t                cAllocated; 
    134137    /** The index of the first free handle entry. 
    135      * ~0U means empty list. */ 
    136     uint32_t volatile   iHead; 
     138     * UINT32_MAX means empty list. */ 
     139    uint32_t volatile       iHead; 
    137140    /** The index of the last free handle entry. 
    138      * ~0U means empty list. */ 
    139     uint32_t volatile   iTail; 
    140 } INTNETHT, *PINTNETHT; 
     141     * UINT32_MAX means empty list. */ 
     142    uint32_t volatile       iTail; 
     143} INTNETHT; 
     144typedef INTNETHT *PINTNETHT; 
    141145 
    142146 
     
    181185    if (    i < pHT->cAllocated 
    182186        &&  pHT->paEntries[i].iNext >= INTNET_HANDLE_MAX 
    183         &&  pHT->paEntries[i].iNext != ~0U
     187        &&  pHT->paEntries[i].iNext != UINT32_MAX
    184188        pIF = pHT->paEntries[i].pIF; 
    185189 
     
    214218         */ 
    215219        uint32_t i = pHT->iHead; 
    216         if (i != ~0U
     220        if (i != UINT32_MAX
    217221        { 
    218222            pHT->iHead = pHT->paEntries[i].iNext; 
    219             if (pHT->iHead == ~0U
    220                 pHT->iTail = ~0U
     223            if (pHT->iHead == UINT32_MAX
     224                pHT->iTail = UINT32_MAX
    221225 
    222226            pHT->paEntries[i].pIF = pIF; 
     
    253257            i = pHT->cAllocated; 
    254258            uint32_t iTail = pHT->iTail; 
    255             if (iTail == ~0U
     259            if (iTail == UINT32_MAX
    256260                pHT->iHead = iTail = i++; 
    257261            while (i < cNew) 
     
    260264                iTail = i++; 
    261265            } 
    262             paNew[iTail].iNext = ~0U
     266            paNew[iTail].iNext = UINT32_MAX
    263267            pHT->iTail = iTail; 
    264268 
     
    297301         * Insert at the end of the free list. 
    298302         */ 
    299         pHT->paEntries[i].iNext = ~0U
     303        pHT->paEntries[i].iNext = UINT32_MAX
    300304        const uint32_t iTail = pHT->iTail; 
    301         if (iTail != ~0U
     305        if (iTail != UINT32_MAX
    302306            pHT->paEntries[iTail].iNext = i; 
    303307        else 
     
    446450    PDMMAC  MacDst; 
    447451    PDMMAC  MacSrc; 
    448 } INTNETETHERHDR, *PINTNETETHERHDR
     452} INTNETETHERHDR
    449453#pragma pack() 
     454typedef INTNETETHERHDR *PINTNETETHERHDR; 
    450455 
    451456 
     
    15581563        //pIntNet->IfHandles.paEntries    = NULL; 
    15591564        //pIntNet->IfHandles.cAllocated   = 0; 
    1560         pIntNet->IfHandles.iHead        = ~0U
    1561         pIntNet->IfHandles.iTail        = ~0U
     1565        pIntNet->IfHandles.iHead        = UINT32_MAX
     1566        pIntNet->IfHandles.iTail        = UINT32_MAX
    15621567 
    15631568        rc = RTSemFastMutexCreate(&pIntNet->FastMutex); 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy