VirtualBox

Changeset 8285 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Apr 22, 2008 1:04:46 PM (17 years ago)
Author:
vboxsync
Message:

NAT: set network address after loadstate (fixed #2467)

Location:
trunk/src/VBox/Devices/Network
Files:
3 edited

Legend:

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

    r8155 r8285  
    4848    /** The port we're attached to. */
    4949    PPDMINETWORKPORT        pPort;
     50    /** The network config of the port we're attached to. */
     51    PPDMINETWORKCONFIG      pConfig;
    5052    /** Pointer to the driver instance. */
    5153    PPDMDRVINS              pDrvIns;
     
    8890static DECLCALLBACK(int) drvNATSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
    8991{
    90     PDRVNAT    pData = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface);
     92    PDRVNAT pData = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface);
    9193
    9294    LogFlow(("drvNATSend: pvBuf=%p cb=%#x\n", pvBuf, cb));
     
    133135static DECLCALLBACK(void) drvNATNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
    134136{
    135     PDRVNAT    pData = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface);
     137    PDRVNAT pData = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface);
    136138
    137139    LogFlow(("drvNATNotifyLinkChanged: enmLinkState=%d\n", enmLinkState));
     
    359361}
    360362
     363static DECLCALLBACK(int) drvNATLoadDone(PPDMDRVINS pDrvIns, PSSMHANDLE pSSMHandle)
     364{
     365    PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT);
     366    PDMMAC  Mac;
     367    if (pData->pConfig)
     368        pData->pConfig->pfnGetMac(pData->pConfig, &Mac);
     369    slirp_set_ethaddr(pData->pNATState, Mac.au8);
     370    return VINF_SUCCESS;
     371}
     372
    361373
    362374/**
     
    420432        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
    421433                                N_("Configuration error: the above device/driver didn't export the network port interface"));
     434    pData->pConfig = (PPDMINETWORKCONFIG)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_NETWORK_CONFIG);
     435    if (!pData->pConfig)
     436        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
     437                                N_("Configuration error: the above device/driver didn't export the network config interface"));
    422438
    423439    /* Generate a network address for this network card. */
     
    451467                if (VBOX_SUCCESS(rc2))
    452468                {
     469                    rc2 = pDrvIns->pDrvHlp->pfnSSMRegister(pDrvIns, pDrvIns->pDrvReg->szDriverName, 0, 0,
     470                                                           pDrvIns->iInstance, NULL, NULL, NULL, NULL, NULL,
     471                                                           drvNATLoadDone);
     472                    AssertRC(rc2);
    453473                    pDrvIns->pDrvHlp->pfnPDMPollerRegister(pDrvIns, drvNATPoller);
    454474
     
    462482                }
    463483                /* failure path */
     484                rc = rc2;
    464485                slirp_term(pData->pNATState);
    465486                pData->pNATState = NULL;
  • trunk/src/VBox/Devices/Network/slirp/libslirp.h

    r8009 r8285  
    3838
    3939void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len);
     40void slirp_set_ethaddr(PNATState pData, const uint8_t *ethaddr);
    4041
    4142/* you must provide the following functions: */
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r8009 r8285  
    812812                    addr_low_byte, htons(guest_port));
    813813}
     814
     815void slirp_set_ethaddr(PNATState pData, const uint8_t *ethaddr)
     816{
     817    memcpy(client_ethaddr, ethaddr, ETH_ALEN);
     818}
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