VirtualBox

Changeset 20716 in vbox


Ignore:
Timestamp:
Jun 19, 2009 12:00:41 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
48829
Message:

DrvNAT: nit picking

File:
1 edited

Legend:

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

    r20714 r20716  
    4343# include <fcntl.h>
    4444# include <poll.h>
    45 #endif
    46 #include <errno.h>
     45# include <errno.h>
     46#endif
    4747#include <iprt/semaphore.h>
    4848#include <iprt/req.h>
     
    140140}
    141141
     142
    142143/**
    143144 * Send data to the network.
     
    218219}
    219220
     221
    220222/**
    221223 * Worker function for drvNATNotifyLinkChanged().
     
    243245    }
    244246}
     247
    245248
    246249/**
     
    418421}
    419422
    420  /**
    421  *  Unblock the send thread so it can respond to a state change.
    422  *
    423  *  @returns VBox status code.
    424  *  @param   pDevIns     The pcnet device instance.
    425  *  @param   pThread     The send thread.
     423
     424/**
     425 * Unblock the send thread so it can respond to a state change.
     426 *
     427 * @returns VBox status code.
     428 * @param   pDevIns     The pcnet device instance.
     429 * @param   pThread     The send thread.
    426430 */
    427431static DECLCALLBACK(int) drvNATAsyncIoWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
     
    442446
    443447#ifdef VBOX_WITH_SLIRP_MT
     448
    444449static DECLCALLBACK(int) drvNATAsyncIoGuest(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
    445450{
     
    454459}
    455460
     461
    456462static DECLCALLBACK(int) drvNATAsyncIoGuestWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
    457463{
     
    460466    return VINF_SUCCESS;
    461467}
     468
    462469#endif /* VBOX_WITH_SLIRP_MT */
    463 
    464470
    465471/**
     
    513519    RTMemFree((void *)pu8Buf);
    514520}
     521
    515522
    516523/**
     
    551558}
    552559
     560
    553561/**
    554562 * Queries an interface to the driver.
     
    577585
    578586/**
    579  * Destruct a driver instance.
    580  *
    581  * Most VM resources are freed by the VM. This callback is provided so that any non-VM
    582  * resources can be freed correctly.
    583  *
    584  * @param   pDrvIns     The driver instance data.
    585  */
    586 static DECLCALLBACK(void) drvNATDestruct(PPDMDRVINS pDrvIns)
     587 * Get the MAC address into the slirp stack.
     588 *
     589 * Called by drvNATLoadDone and drvNATPowerOn.
     590 */
     591static void drvNATSetMac(PDRVNAT pThis)
     592{
     593    if (pThis->pConfig)
     594    {
     595        RTMAC Mac;
     596        pThis->pConfig->pfnGetMac(pThis->pConfig, &Mac);
     597        slirp_set_ethaddr(pThis->pNATState, Mac.au8);
     598    }
     599}
     600
     601
     602/**
     603 * After loading we have to pass the MAC address of the ethernet device to the slirp stack.
     604 * Otherwise the guest is not reachable until it performs a DHCP request or an ARP request
     605 * (usually done during guest boot).
     606 */
     607static DECLCALLBACK(int) drvNATLoadDone(PPDMDRVINS pDrvIns, PSSMHANDLE pSSMHandle)
    587608{
    588609    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
    589 
    590     LogFlow(("drvNATDestruct:\n"));
    591 
    592     slirp_term(pThis->pNATState);
    593     slirp_deregister_statistics(pThis->pNATState, pDrvIns);
    594     pThis->pNATState = NULL;
    595 #ifdef VBOX_WITH_STATISTICS
    596     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktSent);
    597     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktDropped);
    598 #endif
     610    drvNATSetMac(pThis);
     611    return VINF_SUCCESS;
     612}
     613
     614
     615/**
     616 * Some guests might not use DHCP to retrieve an IP but use a static IP.
     617 */
     618static DECLCALLBACK(void) drvNATPowerOn(PPDMDRVINS pDrvIns)
     619{
     620    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
     621    drvNATSetMac(pThis);
    599622}
    600623
     
    680703}
    681704
    682 /**
    683  * Get the MAC address into the slirp stack.
    684  */
    685 static void drvNATSetMac(PDRVNAT pThis)
    686 {
    687     if (pThis->pConfig)
    688     {
    689         RTMAC Mac;
    690         pThis->pConfig->pfnGetMac(pThis->pConfig, &Mac);
    691         slirp_set_ethaddr(pThis->pNATState, Mac.au8);
    692     }
    693 }
    694 
    695 
    696 /**
    697  * After loading we have to pass the MAC address of the ethernet device to the slirp stack.
    698  * Otherwise the guest is not reachable until it performs a DHCP request or an ARP request
    699  * (usually done during guest boot).
    700  */
    701 static DECLCALLBACK(int) drvNATLoadDone(PPDMDRVINS pDrvIns, PSSMHANDLE pSSMHandle)
     705
     706/**
     707 * Destruct a driver instance.
     708 *
     709 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
     710 * resources can be freed correctly.
     711 *
     712 * @param   pDrvIns     The driver instance data.
     713 */
     714static DECLCALLBACK(void) drvNATDestruct(PPDMDRVINS pDrvIns)
    702715{
    703716    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
    704     drvNATSetMac(pThis);
    705     return VINF_SUCCESS;
    706 }
    707 
    708 
    709 /**
    710  * Some guests might not use DHCP to retrieve an IP but use a static IP.
    711  */
    712 static DECLCALLBACK(void) drvNATPowerOn(PPDMDRVINS pDrvIns)
    713 {
    714     PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
    715     drvNATSetMac(pThis);
     717
     718    LogFlow(("drvNATDestruct:\n"));
     719
     720    slirp_term(pThis->pNATState);
     721    slirp_deregister_statistics(pThis->pNATState, pDrvIns);
     722    pThis->pNATState = NULL;
     723#ifdef VBOX_WITH_STATISTICS
     724    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktSent);
     725    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktDropped);
     726#endif
    716727}
    717728
     
    955966    NULL
    956967};
     968
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