VirtualBox

Changeset 13967 in vbox


Ignore:
Timestamp:
Nov 7, 2008 3:16:56 PM (16 years ago)
Author:
vboxsync
Message:

dropped VBOX_NAT_SOURCES here to make the code easier to understand

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r13951 r13967  
    2828#define __STDC_LIMIT_MACROS
    2929#define __STDC_CONSTANT_MACROS
    30 #ifndef VBOX_NAT_SOURCES
    3130#include "Network/slirp/libslirp.h"
    32 #else
    33 #include <sys/types.h>
    34 #include <sys/socket.h>
    35 
    36 #include <netinet/in.h>
    37 
    38 #include <errno.h>
    39 
    40 #include <unistd.h>
    41 
    42 #include <fcntl.h>
    43 
    44 #include <string.h>
    45 
    46 #endif
    4731#include <VBox/pdmdrv.h>
    4832#include <iprt/assert.h>
     
    5337
    5438#include "Builtins.h"
    55 
    56 #ifdef VBOX_NAT_SOURCES
    57 #include "Network/nat/nat.h"
    58 #endif
    5939
    6040#ifdef VBOX_WITH_SYNC_SLIRP
     
    8666    PDMNETWORKLINKSTATE     enmLinkState;
    8767    /** NAT state for this instance. */
    88 #ifndef VBOX_NAT_SOURCES
    8968    PNATState               pNATState;
    90 #endif
    9169    /** TFTP directory prefix. */
    9270    char                    *pszTFTPPrefix;
     
    9775    PPDMTHREAD              pThread;
    9876    /*used for wakep of poling thread*/
    99     RTSEMEVENT               semIOmutex;
    100     PTMTIMER                 pNATFastTimer;
    101     PTMTIMER                 pNATSlowTimer;
     77    RTSEMEVENT              semIOmutex;
     78    PTMTIMER                pNATFastTimer;
     79    PTMTIMER                pNATSlowTimer;
    10280    /** The write end of the control pipe. */
    10381    RTFILE                  PipeWrite;
     
    127105
    128106
    129 #ifdef VBOX_NAT_SOURCES
    130 /*
    131  * Sends data to guest called from NAT glue code
    132  */
    133 static DECLCALLBACK(void) drvNATOutput(const void * data, const uint8_t *msg, int size)
    134 {
    135         PDRVNAT pThis = (PDRVNAT)(void *)data;
    136         LogFlow(("output: pvBuf=%p cb=%#x\n", msg, size));
    137         int rc =  pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0);
    138         if (RT_SUCCESS(rc))
    139                 pThis->pPort->pfnReceive(pThis->pPort, msg, size);
    140         LogFlow(("output: exit\n"));
    141 }
    142 
    143 #endif
    144 
    145107/**
    146108 * Send data to the network.
     
    168130    Assert(pThis->enmLinkState == PDMNETWORKLINKSTATE_UP);
    169131    if (pThis->enmLinkState == PDMNETWORKLINKSTATE_UP) {
    170 #ifndef VBOX_NAT_SOURCES
    171132        slirp_input(pThis->pNATState, (uint8_t *)pvBuf, cb);
    172 #else
    173         ether_chk(pThis, pvBuf, cb);
    174 #endif
    175133    }
    176134#ifndef VBOX_WITH_SYNC_SLIRP
     
    232190        case PDMNETWORKLINKSTATE_UP:
    233191            LogRel(("NAT: link up\n"));
    234 #ifndef VBOX_NAT_SOURCES
    235192            slirp_link_up(pThis->pNATState);
    236 #endif
    237193            break;
    238194
     
    240196        case PDMNETWORKLINKSTATE_DOWN_RESUME:
    241197            LogRel(("NAT: link down\n"));
    242 #ifndef VBOX_NAT_SOURCES
    243198            slirp_link_down(pThis->pNATState);
    244 #endif
    245199            break;
    246200
     
    272226    AssertReleaseRC(rc);
    273227
    274 #ifndef VBOX_NAT_SOURCES
    275228    slirp_select_fill(pThis->pNATState, &cFDs, &ReadFDs, &WriteFDs, &XcptFDs);
    276 #else
    277     nat_select_fill(NULL, &cFDs, &ReadFDs, &WriteFDs, &XcptFDs);
    278 #endif
    279229
    280230    struct timeval tv = {0, 0}; /* no wait */
    281231    int cReadFDs = select(cFDs + 1, &ReadFDs, &WriteFDs, &XcptFDs, &tv);
    282 #ifndef VBOX_NAT_SOURCES
    283232    if (cReadFDs >= 0)
    284233        slirp_select_poll(pThis->pNATState, &ReadFDs, &WriteFDs, &XcptFDs);
    285 #else
    286     if (cReadFDs >= 0) {
    287         nat_select_poll(pThis, &ReadFDs, &WriteFDs, &XcptFDs);
    288     }
    289 #endif
    290234
    291235    RTCritSectLeave(&pThis->CritSect);
     
    308252    TMTimerSetMicro(pTimer, 500);
    309253}
     254
    310255static DECLCALLBACK(int) drvNATAsyncIoThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
    311256{
     
    318263
    319264    LogFlow(("drvNATAsyncIoThread: pThis=%p\n", pThis));
    320 
    321265
    322266    if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
     
    386330#endif
    387331
    388 #ifndef VBOX_NAT_SOURCES
    389332/**
    390333 * Function called by slirp to check if it's possible to feed incoming data to the network port.
     
    434377    LogFlow(("slirp_output END %x %d\n", pu8Buf, cb));
    435378}
    436 #endif
    437379
    438380/**
     
    477419    int rc = RTCritSectEnter(&pThis->CritSect);
    478420    AssertReleaseRC(rc);
    479 #ifndef VBOX_NAT_SOURCES
    480421    slirp_term(pThis->pNATState);
    481422    pThis->pNATState = NULL;
    482 #endif
    483423    RTCritSectLeave(&pThis->CritSect);
    484424
     
    495435static int drvNATConstructRedir(unsigned iInstance, PDRVNAT pThis, PCFGMNODE pCfgHandle, RTIPV4ADDR Network)
    496436{
    497 #ifndef VBOX_NAT_SOURCES
    498437    /*
    499438     * Enumerate redirections.
     
    562501            return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_NAT_REDIR_SETUP, RT_SRC_POS, N_("NAT#%d: configuration error: failed to set up redirection of %d to %s:%d. Probably a conflict with existing services or other rules"), iInstance, iHostPort, szGuestIP, iGuestPort);
    563502    } /* for each redir rule */
    564 #endif
    565503
    566504    return VINF_SUCCESS;
     
    572510static void drvNATSetMac(PDRVNAT pThis)
    573511{
    574 #ifndef VBOX_NAT_SOURCES
    575512    if (pThis->pConfig)
    576513    {
     
    579516        slirp_set_ethaddr(pThis->pNATState, Mac.au8);
    580517    }
    581 #endif
    582518}
    583519
     
    633569     */
    634570    pThis->pDrvIns                      = pDrvIns;
    635 #ifndef VBOX_NAT_SOURCES
    636571    pThis->pNATState                    = NULL;
    637 #endif
    638572    pThis->pszTFTPPrefix                = NULL;
    639573    pThis->pszBootFile                  = NULL;
     
    708642        {
    709643#endif
    710 #ifndef VBOX_NAT_SOURCES
    711644            /*
    712645             * Initialize slirp.
     
    774707              AssertMsgFailed(("Add error message for rc=%d (%Rrc)\n", rc, rc));
    775708            }
    776 #else
    777         pDrvIns->pDrvHlp->pfnPDMPollerRegister(pDrvIns, drvNATPoller);
    778         pThis->enmLinkState = PDMNETWORKLINKSTATE_UP;
    779         struct nat_output_callbacks cb;
    780         cb.noc_guest_out = drvNATOutput;
    781         nat_init(&cb, pDrvIns);
    782 #endif
    783709#if 0
    784710            g_fThreadTerm = true;
     
    790716    }
    791717#endif
    792 #ifndef VBOX_NAT_SOURCES
    793718    RTCritSectDelete(&pThis->CritSect);
    794 #endif
    795719    return rc;
    796720}
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