VirtualBox

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


Ignore:
Timestamp:
Jun 30, 2008 9:05:06 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
32477
Message:

netsniffer: implemented missing config interface allow to sniffing NAT-bound network cards

File:
1 edited

Legend:

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

    r8155 r10009  
    5252    /** The network interface. */
    5353    PDMINETWORKPORT         INetworkPort;
     54    /** The network config interface. */
     55    PDMINETWORKCONFIG       INetworkConfig;
    5456    /** The port we're attached to. */
    5557    PPDMINETWORKPORT        pPort;
     58    /** The config port interface we're attached to. */
     59    PPDMINETWORKCONFIG      pConfig;
    5660    /** The connector that's attached to us. */
    5761    PPDMINETWORKCONNECTOR   pConnector;
     
    7276/** Converts a pointer to NAT::INetworkPort to a PDRVNETSNIFFER. */
    7377#define PDMINETWORKPORT_2_DRVNETSNIFFER(pInterface)         ( (PDRVNETSNIFFER)((uintptr_t)pInterface - RT_OFFSETOF(DRVNETSNIFFER, INetworkPort)) )
     78
     79/** Converts a pointer to NAT::INetworkConfig to a PDRVNETSNIFFER. */
     80#define PDMINETWORKCONFIG_2_DRVNETSNIFFER(pInterface)       ( (PDRVNETSNIFFER)((uintptr_t)pInterface - RT_OFFSETOF(DRVNETSNIFFER, INetworkConfig)) )
    7481
    7582
     
    240247}
    241248
     249
     250/**
     251 * Gets the current Media Access Control (MAC) address.
     252 *
     253 * @returns VBox status code.
     254 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     255 * @param   pMac            Where to store the MAC address.
     256 * @thread  EMT
     257 */
     258static DECLCALLBACK(int) drvNetSnifferGetMac(PPDMINETWORKCONFIG pInterface, PPDMMAC pMac)
     259{
     260    PDRVNETSNIFFER pData = PDMINETWORKCONFIG_2_DRVNETSNIFFER(pInterface);
     261    return pData->pConfig->pfnGetMac(pData->pConfig, pMac);
     262}
     263
     264/**
     265 * Gets the new link state.
     266 *
     267 * @returns The current link state.
     268 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     269 * @thread  EMT
     270 */
     271static DECLCALLBACK(PDMNETWORKLINKSTATE) drvNetSnifferGetLinkState(PPDMINETWORKCONFIG pInterface)
     272{
     273    PDRVNETSNIFFER pData = PDMINETWORKCONFIG_2_DRVNETSNIFFER(pInterface);
     274    return pData->pConfig->pfnGetLinkState(pData->pConfig);
     275}
     276
     277/**
     278 * Sets the new link state.
     279 *
     280 * @returns VBox status code.
     281 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     282 * @param   enmState        The new link state
     283 * @thread  EMT
     284 */
     285static DECLCALLBACK(int) drvNetSnifferSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState)
     286{
     287    PDRVNETSNIFFER pData = PDMINETWORKCONFIG_2_DRVNETSNIFFER(pInterface);
     288    return pData->pConfig->pfnSetLinkState(pData->pConfig, enmState);
     289}
     290
     291
    242292/**
    243293 * Queries an interface to the driver.
     
    261311        case PDMINTERFACE_NETWORK_PORT:
    262312            return &pData->INetworkPort;
     313        case PDMINTERFACE_NETWORK_CONFIG:
     314            return &pData->INetworkConfig;
    263315        default:
    264316            return NULL;
     
    325377    pData->INetworkPort.pfnWaitReceiveAvail         = drvNetSnifferWaitReceiveAvail;
    326378    pData->INetworkPort.pfnReceive                  = drvNetSnifferReceive;
     379    /* INetworkConfig */
     380    pData->INetworkConfig.pfnGetMac                 = drvNetSnifferGetMac;
     381    pData->INetworkConfig.pfnGetLinkState           = drvNetSnifferGetLinkState;
     382    pData->INetworkConfig.pfnSetLinkState           = drvNetSnifferSetLinkState;
    327383
    328384    /*
     
    345401    {
    346402        AssertMsgFailed(("Configuration error: the above device/driver didn't export the network port interface!\n"));
     403        return VERR_PDM_MISSING_INTERFACE_ABOVE;
     404    }
     405
     406    /*
     407     * Query the network config interface.
     408     */
     409    pData->pConfig = (PPDMINETWORKCONFIG)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_NETWORK_CONFIG);
     410    if (!pData->pConfig)
     411    {
     412        AssertMsgFailed(("Configuration error: the above device/driver didn't export the network config interface!\n"));
    347413        return VERR_PDM_MISSING_INTERFACE_ABOVE;
    348414    }
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