VirtualBox

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


Ignore:
Timestamp:
Feb 5, 2010 7:00:45 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57374
Message:

pdmnetif.h & users: sketched out a new interface that is intended to be similar to the ring-0 and raw-mode context interfaces (working on driver allocated buffers during xmit).

Location:
trunk/src/VBox/Devices
Files:
9 edited

Legend:

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

    r26300 r26305  
    835835 * Device state structure. Holds the current state of device.
    836836 *
    837  * @implements  PDMINETWORKPORT
     837 * @implements  PDMINETWORKDOWN
    838838 * @implements  PDMINETWORKCONFIG
    839839 * @implements  PDMILEDPORTS
     
    843843    char                    szInstance[8];        /**< Instance name, e.g. E1000#1. */
    844844    PDMIBASE                IBase;
    845     PDMINETWORKPORT         INetworkPort;
     845    PDMINETWORKDOWN         INetworkDown;
    846846    PDMINETWORKCONFIG       INetworkConfig;
    847847    PDMILEDPORTS            ILeds;                               /**< LED interface */
    848848    R3PTRTYPE(PPDMIBASE)    pDrvBase;                 /**< Attached network driver. */
    849     R3PTRTYPE(PPDMINETWORKCONNECTOR) pDrv;    /**< Connector of attached network driver. */
     849    R3PTRTYPE(PPDMINETWORKUP) pDrv;    /**< Connector of attached network driver. */
    850850    R3PTRTYPE(PPDMILEDCONNECTORS)    pLedsConnector;
    851851
     
    28332833        e1kMutexRelease(pState);
    28342834        STAM_PROFILE_ADV_START(&pState->StatTransmitSend, a);
    2835         int rc = pState->pDrv->pfnSend(pState->pDrv, pFrame, u16FrameLen);
     2835        int rc = pState->pDrv->pfnSendDeprecated(pState->pDrv, pFrame, u16FrameLen);
    28362836        STAM_PROFILE_ADV_STOP(&pState->StatTransmitSend, a);
    28372837        if (rc != VINF_SUCCESS)
     
    41044104}
    41054105
    4106 static DECLCALLBACK(int) e1kWaitReceiveAvail(PPDMINETWORKPORT pInterface, RTMSINTERVAL cMillies)
    4107 {
    4108     E1KSTATE *pState = IFACE_TO_STATE(pInterface, INetworkPort);
     4106static DECLCALLBACK(int) e1kWaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
     4107{
     4108    E1KSTATE *pState = IFACE_TO_STATE(pInterface, INetworkDown);
    41094109    int rc = e1kCanReceive(pState);
    41104110
     
    43104310 * @thread  ???
    43114311 */
    4312 static DECLCALLBACK(int) e1kReceive(PPDMINETWORKPORT pInterface, const void *pvBuf, size_t cb)
    4313 {
    4314     E1KSTATE *pState = IFACE_TO_STATE(pInterface, INetworkPort);
     4312static DECLCALLBACK(int) e1kReceive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb)
     4313{
     4314    E1KSTATE *pState = IFACE_TO_STATE(pInterface, INetworkDown);
    43154315    int       rc = VINF_SUCCESS;
    43164316
     
    44694469
    44704470    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    4471     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKPORT, &pThis->INetworkPort);
     4471    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown);
    44724472    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONFIG, &pThis->INetworkConfig);
    44734473    PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->ILeds);
     
    47984798#endif
    47994799        }
    4800         pState->pDrv = PDMIBASE_QUERY_INTERFACE(pState->pDrvBase, PDMINETWORKCONNECTOR);
    4801         AssertMsgStmt(pState->pDrv, ("Failed to obtain the PDMINETWORKCONNECTOR interface!\n"),
     4800        pState->pDrv = PDMIBASE_QUERY_INTERFACE(pState->pDrvBase, PDMINETWORKUP);
     4801        AssertMsgStmt(pState->pDrv, ("Failed to obtain the PDMINETWORKUP interface!\n"),
    48024802                      rc = VERR_PDM_MISSING_INTERFACE_BELOW);
    48034803    }
     
    51135113    /* Interfaces */
    51145114    pState->IBase.pfnQueryInterface          = e1kQueryInterface;
    5115     pState->INetworkPort.pfnWaitReceiveAvail = e1kWaitReceiveAvail;
    5116     pState->INetworkPort.pfnReceive          = e1kReceive;
     5115    pState->INetworkDown.pfnWaitReceiveAvail = e1kWaitReceiveAvail;
     5116    pState->INetworkDown.pfnReceive          = e1kReceive;
    51175117    pState->ILeds.pfnQueryStatusLed          = e1kQueryStatusLed;
    51185118    pState->INetworkConfig.pfnGetMac         = e1kGetMac;
     
    52535253                                       N_("A Domain Name Server (DNS) for NAT networking could not be determined. Ensure that your host is correctly connected to an ISP. If you ignore this warning the guest will not be able to perform nameserver lookups and it will probably observe delays if trying so"));
    52545254        }
    5255         pState->pDrv = PDMIBASE_QUERY_INTERFACE(pState->pDrvBase, PDMINETWORKCONNECTOR);
    5256         AssertMsgReturn(pState->pDrv, ("Failed to obtain the PDMINETWORKCONNECTOR interface!\n"),
     5255        pState->pDrv = PDMIBASE_QUERY_INTERFACE(pState->pDrvBase, PDMINETWORKUP);
     5256        AssertMsgReturn(pState->pDrv, ("Failed to obtain the PDMINETWORKUP interface!\n"),
    52575257                        VERR_PDM_MISSING_INTERFACE_BELOW);
    52585258    }
  • trunk/src/VBox/Devices/Network/DevINIP.cpp

    r26300 r26305  
    7171 *
    7272 * @implements PDMIBASE
    73  * @implements PDMINETWORKPORT
     73 * @implements PDMINETWORKDOWN
    7474 */
    7575typedef struct DEVINTNETIP
     
    7878    PDMIBASE                IBase;
    7979    /** The network port this device provides (LUN\#0). */
    80     PDMINETWORKPORT         INetworkPort;
     80    PDMINETWORKDOWN         INetworkDown;
    8181    /** The base interface of the network driver below us. */
    8282    PPDMIBASE               pDrvBase;
    8383    /** The connector of the network driver below us. */
    84     PPDMINETWORKCONNECTOR   pDrv;
     84    PPDMINETWORKUP   pDrv;
    8585    /** Pointer to the device instance. */
    8686    PPDMDEVINSR3            pDevIns;
     
    254254    }
    255255    if (cbBuf)
    256         rc = g_pDevINIPData->pDrv->pfnSend(g_pDevINIPData->pDrv,
    257                                                  &aFrame[0], cbBuf);
     256        rc = g_pDevINIPData->pDrv->pfnSendDeprecated(g_pDevINIPData->pDrv,
     257                                                     &aFrame[0], cbBuf);
    258258
    259259#if ETH_PAD_SIZE
     
    300300 * @param   cMillies    Number of milliseconds to wait. 0 means return immediately.
    301301 */
    302 static DECLCALLBACK(int) devINIPWaitInputAvail(PPDMINETWORKPORT pInterface, RTMSINTERVAL cMillies)
     302static DECLCALLBACK(int) devINIPWaitInputAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
    303303{
    304304    LogFlow(("%s: pInterface=%p\n", __FUNCTION__, pInterface));
     
    315315 * @param   cb          Frame size.
    316316 */
    317 static DECLCALLBACK(int) devINIPInput(PPDMINETWORKPORT pInterface,
     317static DECLCALLBACK(int) devINIPInput(PPDMINETWORKDOWN pInterface,
    318318                                      const void *pvBuf, size_t cb)
    319319{
     
    400400    PDEVINTNETIP pThis = RT_FROM_MEMBER(pInterface, DEVINTNETIP, IBase);
    401401    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    402     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKPORT, &pThis->INetworkPort);
     402    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown);
    403403    return NULL;
    404404}
     
    477477    /* IBase */
    478478    pThis->IBase.pfnQueryInterface          = devINIPQueryInterface;
    479     /* INetworkPort */
    480     pThis->INetworkPort.pfnWaitReceiveAvail = devINIPWaitInputAvail;
    481     pThis->INetworkPort.pfnReceive          = devINIPInput;
     479    /* INetworkDown */
     480    pThis->INetworkDown.pfnWaitReceiveAvail = devINIPWaitInputAvail;
     481    pThis->INetworkDown.pfnReceive          = devINIPInput;
    482482
    483483    /*
     
    558558    else
    559559    {
    560         pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKCONNECTOR);
     560        pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKUP);
    561561        if (!pThis->pDrv)
    562562        {
    563             AssertMsgFailed(("Failed to obtain the PDMINETWORKCONNECTOR interface!\n"));
     563            AssertMsgFailed(("Failed to obtain the PDMINETWORKUP interface!\n"));
    564564            rc = VERR_PDM_MISSING_INTERFACE_BELOW;
    565565            goto out;
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r26300 r26305  
    115115 * @extends     PCIDEVICE
    116116 * @implements  PDMIBASE
    117  * @implements  PDMINETWORKPORT
     117 * @implements  PDMINETWORKDOWN
    118118 * @implements  PDMINETWORKCONFIG
    119119 * @implements  PDMILEDPORTS
     
    204204    PTMTIMERR3                          pTimerRestore;
    205205    /** Pointer to the connector of the attached network driver. */
    206     R3PTRTYPE(PPDMINETWORKCONNECTOR)    pDrv;
     206    R3PTRTYPE(PPDMINETWORKUP)    pDrv;
    207207    /** Pointer to the attached network driver. */
    208208    R3PTRTYPE(PPDMIBASE)                pDrvBase;
     
    210210    PDMIBASE                            IBase;
    211211    /** LUN\#0: The network port interface. */
    212     PDMINETWORKPORT                     INetworkPort;
     212    PDMINETWORKDOWN                     INetworkDown;
    213213    /** LUN\#0: The network config port interface. */
    214214    PDMINETWORKCONFIG                   INetworkConfig;
     
    21642164        pThis->Led.Asserted.s.fWriting = pThis->Led.Actual.s.fWriting = 1;
    21652165
    2166     pThis->pDrv->pfnSend(pThis->pDrv, pThis->pvSendFrame, pThis->cbSendFrame);
     2166    pThis->pDrv->pfnSendDeprecated(pThis->pDrv, pThis->pvSendFrame, pThis->cbSendFrame);
    21672167    STAM_REL_COUNTER_ADD(&pThis->StatTransmitBytes, pThis->cbSendFrame);
    21682168    pThis->Led.Actual.s.fWriting = 0;
     
    44884488    Assert(&pThis->IBase == pInterface);
    44894489    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    4490     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKPORT, &pThis->INetworkPort);
     4490    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown);
    44914491    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONFIG, &pThis->INetworkConfig);
    44924492    PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->ILeds);
     
    44944494}
    44954495
    4496 /** Converts a pointer to PCNetState::INetworkPort to a PCNetState pointer. */
    4497 #define INETWORKPORT_2_DATA(pInterface)  ( (PCNetState *)((uintptr_t)pInterface - RT_OFFSETOF(PCNetState, INetworkPort)) )
     4496/** Converts a pointer to PCNetState::INetworkDown to a PCNetState pointer. */
     4497#define INETWORKPORT_2_DATA(pInterface)  ( (PCNetState *)((uintptr_t)pInterface - RT_OFFSETOF(PCNetState, INetworkDown)) )
    44984498
    44994499
     
    45354535 *
    45364536 */
    4537 static DECLCALLBACK(int) pcnetWaitReceiveAvail(PPDMINETWORKPORT pInterface, RTMSINTERVAL cMillies)
     4537static DECLCALLBACK(int) pcnetWaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
    45384538{
    45394539    PCNetState *pThis = INETWORKPORT_2_DATA(pInterface);
     
    45834583 * @thread  EMT
    45844584 */
    4585 static DECLCALLBACK(int) pcnetReceive(PPDMINETWORKPORT pInterface, const void *pvBuf, size_t cb)
     4585static DECLCALLBACK(int) pcnetReceive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb)
    45864586{
    45874587    PCNetState *pThis = INETWORKPORT_2_DATA(pInterface);
     
    48204820#endif
    48214821        }
    4822         pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKCONNECTOR);
    4823         AssertMsgStmt(pThis->pDrv, ("Failed to obtain the PDMINETWORKCONNECTOR interface!\n"),
     4822        pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKUP);
     4823        AssertMsgStmt(pThis->pDrv, ("Failed to obtain the PDMINETWORKUP interface!\n"),
    48244824                      rc = VERR_PDM_MISSING_INTERFACE_BELOW);
    48254825    }
     
    50105010    pThis->IBase.pfnQueryInterface          = pcnetQueryInterface;
    50115011    /* INeworkPort */
    5012     pThis->INetworkPort.pfnWaitReceiveAvail = pcnetWaitReceiveAvail;
    5013     pThis->INetworkPort.pfnReceive          = pcnetReceive;
     5012    pThis->INetworkDown.pfnWaitReceiveAvail = pcnetWaitReceiveAvail;
     5013    pThis->INetworkDown.pfnReceive          = pcnetReceive;
    50145014    /* INetworkConfig */
    50155015    pThis->INetworkConfig.pfnGetMac         = pcnetGetMac;
     
    52015201#endif
    52025202        }
    5203         pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKCONNECTOR);
    5204         AssertMsgReturn(pThis->pDrv, ("Failed to obtain the PDMINETWORKCONNECTOR interface!\n"),
     5203        pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKUP);
     5204        AssertMsgReturn(pThis->pDrv, ("Failed to obtain the PDMINETWORKUP interface!\n"),
    52055205                        VERR_PDM_MISSING_INTERFACE_BELOW);
    52065206    }
  • trunk/src/VBox/Devices/Network/DevVirtioNet.cpp

    r26300 r26305  
    110110 *
    111111 * @extends     VPCISTATE
    112  * @implements  PDMINETWORKPORT
     112 * @implements  PDMINETWORKDOWN
    113113 * @implements  PDMINETWORKCONFIG
    114114 */
     
    120120//    PDMCRITSECT             csRx;                           /**< Protects RX queue. */
    121121
    122     PDMINETWORKPORT         INetworkPort;
     122    PDMINETWORKDOWN         INetworkDown;
    123123    PDMINETWORKCONFIG       INetworkConfig;
    124124    R3PTRTYPE(PPDMIBASE)    pDrvBase;                 /**< Attached network driver. */
    125     R3PTRTYPE(PPDMINETWORKCONNECTOR) pDrv;    /**< Connector of attached network driver. */
     125    R3PTRTYPE(PPDMINETWORKUP) pDrv;    /**< Connector of attached network driver. */
    126126
    127127    R3PTRTYPE(PPDMQUEUE)    pCanRxQueueR3;           /**< Rx wakeup signaller - R3. */
     
    546546}
    547547
    548 static DECLCALLBACK(int) vnetWaitReceiveAvail(PPDMINETWORKPORT pInterface, RTMSINTERVAL cMillies)
    549 {
    550     VNETSTATE *pState = IFACE_TO_STATE(pInterface, INetworkPort);
     548static DECLCALLBACK(int) vnetWaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
     549{
     550    VNETSTATE *pState = IFACE_TO_STATE(pInterface, INetworkDown);
    551551    LogFlow(("%s vnetWaitReceiveAvail(cMillies=%u)\n", INSTANCE(pState), cMillies));
    552552    int rc = vnetCanReceive(pState);
     
    591591    Assert(&pThis->VPCI.IBase == pInterface);
    592592
    593     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKPORT, &pThis->INetworkPort);
     593    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown);
    594594    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONFIG, &pThis->INetworkConfig);
    595595    return vpciQueryInterface(pInterface, pszIID);
     
    733733 * @thread  RX
    734734 */
    735 static DECLCALLBACK(int) vnetReceive(PPDMINETWORKPORT pInterface, const void *pvBuf, size_t cb)
    736 {
    737     VNETSTATE *pState = IFACE_TO_STATE(pInterface, INetworkPort);
     735static DECLCALLBACK(int) vnetReceive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb)
     736{
     737    VNETSTATE *pState = IFACE_TO_STATE(pInterface, INetworkDown);
    738738
    739739    Log2(("%s vnetReceive: pvBuf=%p cb=%u\n", INSTANCE(pState), pvBuf, cb));
     
    890890
    891891                STAM_PROFILE_START(&pState->StatTransmitSend, a);
    892                 int rc = pState->pDrv->pfnSend(pState->pDrv, pState->pTxBuf, uOffset);
     892                int rc = pState->pDrv->pfnSendDeprecated(pState->pDrv, pState->pTxBuf, uOffset);
    893893                STAM_PROFILE_STOP(&pState->StatTransmitSend, a);
    894894                STAM_REL_COUNTER_ADD(&pState->StatTransmitBytes, uOffset);
     
    15161516#endif
    15171517        }
    1518         pState->pDrv = PDMIBASE_QUERY_INTERFACE(pState->pDrvBase, PDMINETWORKCONNECTOR);
    1519         AssertMsgStmt(pState->pDrv, ("Failed to obtain the PDMINETWORKCONNECTOR interface!\n"),
     1518        pState->pDrv = PDMIBASE_QUERY_INTERFACE(pState->pDrvBase, PDMINETWORKUP);
     1519        AssertMsgStmt(pState->pDrv, ("Failed to obtain the PDMINETWORKUP interface!\n"),
    15201520                      rc = VERR_PDM_MISSING_INTERFACE_BELOW);
    15211521    }
     
    16671667
    16681668    /* Interfaces */
    1669     pState->INetworkPort.pfnWaitReceiveAvail = vnetWaitReceiveAvail;
    1670     pState->INetworkPort.pfnReceive          = vnetReceive;
     1669    pState->INetworkDown.pfnWaitReceiveAvail = vnetWaitReceiveAvail;
     1670    pState->INetworkDown.pfnReceive          = vnetReceive;
    16711671    pState->INetworkConfig.pfnGetMac         = vnetGetMac;
    16721672    pState->INetworkConfig.pfnGetLinkState   = vnetGetLinkState;
     
    17371737                                       N_("A Domain Name Server (DNS) for NAT networking could not be determined. Ensure that your host is correctly connected to an ISP. If you ignore this warning the guest will not be able to perform nameserver lookups and it will probably observe delays if trying so"));
    17381738        }
    1739         pState->pDrv = PDMIBASE_QUERY_INTERFACE(pState->pDrvBase, PDMINETWORKCONNECTOR);
    1740         AssertMsgReturn(pState->pDrv, ("Failed to obtain the PDMINETWORKCONNECTOR interface!\n"),
     1739        pState->pDrv = PDMIBASE_QUERY_INTERFACE(pState->pDrvBase, PDMINETWORKUP);
     1740        AssertMsgReturn(pState->pDrv, ("Failed to obtain the PDMINETWORKUP interface!\n"),
    17411741                        VERR_PDM_MISSING_INTERFACE_BELOW);
    17421742    }
  • trunk/src/VBox/Devices/Network/DrvIntNet.cpp

    r26300 r26305  
    6666 * Internal networking driver instance data.
    6767 *
    68  * @implements  PDMINETWORKCONNECTOR
     68 * @implements  PDMINETWORKUP
    6969 */
    7070typedef struct DRVINTNET
    7171{
    7272    /** The network interface. */
    73     PDMINETWORKCONNECTOR            INetworkConnectorR3;
     73    PDMINETWORKUP                   INetworkUpR3;
    7474    /** The network interface. */
    75     R3PTRTYPE(PPDMINETWORKPORT)     pIPortR3;
     75    R3PTRTYPE(PPDMINETWORKDOWN)     pIAboveNet;
    7676    /** The network config interface.
    7777     * Can (in theory at least) be NULL. */
    78     R3PTRTYPE(PPDMINETWORKCONFIG)   pIConfigIfR3;
     78    R3PTRTYPE(PPDMINETWORKCONFIG)   pIAboveConfigR3;
    7979    /** Pointer to the driver instance. */
    8080    PPDMDRVINSR3                    pDrvInsR3;
     
    125125#ifdef IN_RING3
    126126
    127 /* -=-=-=-=- PDMINETWORKCONNECTOR -=-=-=-=- */
    128 
    129 /** Converts a pointer to DRVINTNET::INetworkConnectorR3 to a PDRVINTNET. */
    130 #define PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface) \
    131     RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkConnectorR3)
     127/* -=-=-=-=- PDMINETWORKUP -=-=-=-=- */
     128
     129/** Converts a pointer to DRVINTNET::INetworkUpR3 to a PDRVINTNET. */
     130#define PDMINETWORKUP_2_DRVINTNET(pInterface) \
     131    RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkUpR3)
    132132
    133133/**
     
    139139static int drvR3IntNetUpdateMacAddress(PDRVINTNET pThis)
    140140{
    141     if (!pThis->pIConfigIfR3)
     141    if (!pThis->pIAboveConfigR3)
    142142        return VINF_SUCCESS;
    143143
     
    147147    SetMacAddressReq.pSession = NIL_RTR0PTR;
    148148    SetMacAddressReq.hIf = pThis->hIf;
    149     int rc = pThis->pIConfigIfR3->pfnGetMac(pThis->pIConfigIfR3, &SetMacAddressReq.Mac);
     149    int rc = pThis->pIAboveConfigR3->pfnGetMac(pThis->pIAboveConfigR3, &SetMacAddressReq.Mac);
    150150    if (RT_SUCCESS(rc))
    151151        rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvInsR3, VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
     
    168168static int drvR3IntNetSetActive(PDRVINTNET pThis, bool fActive)
    169169{
    170     if (!pThis->pIConfigIfR3)
     170    if (!pThis->pIAboveConfigR3)
    171171        return VINF_SUCCESS;
    172172
     
    280280
    281281/**
    282  * Send data to the network.
    283  *
    284  * @returns VBox status code.
    285  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    286  * @param   pvBuf           Data to send.
    287  * @param   cb              Number of bytes to send.
    288  * @thread  EMT
    289  */
    290 static DECLCALLBACK(int) drvR3IntNetSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
    291 {
    292     PDRVINTNET pThis = PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface);
     282 * @interface_method_impl{PDMINETWORKUP,pfnSendDeprecated}
     283 */
     284static DECLCALLBACK(int) drvR3IntNetSendDeprecated(PPDMINETWORKUP pInterface, const void *pvBuf, size_t cb)
     285{
     286    PDRVINTNET pThis = PDMINETWORKUP_2_DRVINTNET(pInterface);
    293287    STAM_PROFILE_START(&pThis->StatTransmit, a);
    294288
     
    337331
    338332/**
    339  * Set promiscuous mode.
    340  *
    341  * This is called when the promiscuous mode is set. This means that there doesn't have
    342  * to be a mode change when it's called.
    343  *
    344  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    345  * @param   fPromiscuous    Set if the adaptor is now in promiscuous mode. Clear if it is not.
    346  * @thread  EMT
    347  */
    348 static DECLCALLBACK(void) drvR3IntNetSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
    349 {
    350     PDRVINTNET pThis = PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface);
     333 * @interface_method_impl{PDMINETWORKUP,pfnSetPromiscuousMode}
     334 */
     335static DECLCALLBACK(void) drvR3IntNetSetPromiscuousMode(PPDMINETWORKUP pInterface, bool fPromiscuous)
     336{
     337    PDRVINTNET pThis = PDMINETWORKUP_2_DRVINTNET(pInterface);
    351338    INTNETIFSETPROMISCUOUSMODEREQ Req;
    352339    Req.Hdr.u32Magic    = SUPVMMR0REQHDR_MAGIC;
     
    362349
    363350/**
    364  * Notification on link status changes.
    365  *
    366  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    367  * @param   enmLinkState    The new link state.
    368  * @thread  EMT
    369  */
    370 static DECLCALLBACK(void) drvR3IntNetNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
    371 {
    372     PDRVINTNET pThis = PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface);
     351 * @interface_method_impl{PDMINETWORKUP,pfnNotifyLinkChanged}
     352 */
     353static DECLCALLBACK(void) drvR3IntNetNotifyLinkChanged(PPDMINETWORKUP pInterface, PDMNETWORKLINKSTATE enmLinkState)
     354{
     355    PDRVINTNET pThis = PDMINETWORKUP_2_DRVINTNET(pInterface);
    373356    bool fLinkDown;
    374357    switch (enmLinkState)
     
    401384    LogFlow(("drvR3IntNetAsyncIoWaitForSpace:\n"));
    402385    STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
    403     int rc = pThis->pIPortR3->pfnWaitReceiveAvail(pThis->pIPortR3, RT_INDEFINITE_WAIT);
     386    int rc = pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, RT_INDEFINITE_WAIT);
    404387    STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
    405388    LogFlow(("drvR3IntNetAsyncIoWaitForSpace: returns %Rrc\n", rc));
     
    452435                 */
    453436                size_t cbFrame = pHdr->cbFrame;
    454                 int rc = pThis->pIPortR3->pfnWaitReceiveAvail(pThis->pIPortR3, 0);
     437                int rc = pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, 0);
    455438                if (rc == VINF_SUCCESS)
    456439                {
     
    464447                          cbFrame, cbFrame, INTNETHdrGetFramePtr(pHdr, pBuf)));
    465448#endif
    466                     rc = pThis->pIPortR3->pfnReceive(pThis->pIPortR3, INTNETHdrGetFramePtr(pHdr, pBuf), cbFrame);
     449                    rc = pThis->pIAboveNet->pfnReceive(pThis->pIAboveNet, INTNETHdrGetFramePtr(pHdr, pBuf), cbFrame);
    467450                    AssertRC(rc);
    468451
     
    629612    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASER0, &pThis->IBaseR0);
    630613    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASERC, &pThis->IBaseRC);
    631     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONNECTOR, &pThis->INetworkConnectorR3);
     614    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKUP, &pThis->INetworkUpR3);
    632615    return NULL;
    633616}
     
    669652    }
    670653    if (   PDMDrvHlpVMTeleportedAndNotFullyResumedYet(pDrvIns)
    671         && pThis->pIConfigIfR3)
     654        && pThis->pIAboveConfigR3)
    672655    {
    673656        /*
     
    688671        Frame.Hdr.DstMac.au16[2] = 0xffff;
    689672        Frame.Hdr.EtherType      = RT_H2BE_U16(0x801e);
    690         int rc = pThis->pIConfigIfR3->pfnGetMac(pThis->pIConfigIfR3, &Frame.Hdr.SrcMac);
     673        int rc = pThis->pIAboveConfigR3->pfnGetMac(pThis->pIAboveConfigR3, &Frame.Hdr.SrcMac);
    691674        if (RT_SUCCESS(rc))
    692             rc = drvR3IntNetSend(&pThis->INetworkConnectorR3, &Frame, sizeof(Frame));
     675            rc = drvR3IntNetSendDeprecated(&pThis->INetworkUpR3, &Frame, sizeof(Frame));
    693676        if (RT_FAILURE(rc))
    694677            LogRel(("IntNet#%u: Sending dummy frame failed: %Rrc\n", pDrvIns->iInstance, rc));
     
    828811    pThis->IBaseR0.pfnQueryInterface                = drvR3IntNetIBaseR0_QueryInterface;
    829812    pThis->IBaseRC.pfnQueryInterface                = drvR3IntNetIBaseRC_QueryInterface;
    830     /* INetwork */
    831     pThis->INetworkConnectorR3.pfnSend              = drvR3IntNetSend;
    832     pThis->INetworkConnectorR3.pfnSetPromiscuousMode= drvR3IntNetSetPromiscuousMode;
    833     pThis->INetworkConnectorR3.pfnNotifyLinkChanged = drvR3IntNetNotifyLinkChanged;
     813    /* INetworkUp */
     814    pThis->INetworkUpR3.pfnSendDeprecated           = drvR3IntNetSendDeprecated;
     815    pThis->INetworkUpR3.pfnSetPromiscuousMode       = drvR3IntNetSetPromiscuousMode;
     816    pThis->INetworkUpR3.pfnNotifyLinkChanged        = drvR3IntNetNotifyLinkChanged;
    834817
    835818    /*
     
    865848     * Query the network port interface.
    866849     */
    867     pThis->pIPortR3 = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKPORT);
    868     if (!pThis->pIPortR3)
     850    pThis->pIAboveNet = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKDOWN);
     851    if (!pThis->pIAboveNet)
    869852    {
    870853        AssertMsgFailed(("Configuration error: the above device/driver didn't export the network port interface!\n"));
    871854        return VERR_PDM_MISSING_INTERFACE_ABOVE;
    872855    }
    873     pThis->pIConfigIfR3 = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKCONFIG);
     856    pThis->pIAboveConfigR3 = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKCONFIG);
    874857
    875858    /*
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r26300 r26305  
    121121 * NAT network transport driver instance data.
    122122 *
    123  * @implements  PDMINETWORKCONNECTOR
     123 * @implements  PDMINETWORKUP
    124124 */
    125125typedef struct DRVNAT
    126126{
    127127    /** The network interface. */
    128     PDMINETWORKCONNECTOR    INetworkConnector;
     128    PDMINETWORKUP           INetworkUp;
    129129    /** The port we're attached to. */
    130     PPDMINETWORKPORT        pPort;
     130    PPDMINETWORKDOWN        pIAboveNet;
    131131    /** The network config of the port we're attached to. */
    132     PPDMINETWORKCONFIG      pConfig;
     132    PPDMINETWORKCONFIG      pIAboveConfig;
    133133    /** Pointer to the driver instance. */
    134134    PPDMDRVINS              pDrvIns;
     
    217217
    218218
    219 /** Converts a pointer to NAT::INetworkConnector to a PRDVNAT. */
    220 #define PDMINETWORKCONNECTOR_2_DRVNAT(pInterface)   ( (PDRVNAT)((uintptr_t)pInterface - RT_OFFSETOF(DRVNAT, INetworkConnector)) )
     219/** Converts a pointer to NAT::INetworkUp to a PRDVNAT. */
     220#define PDMINETWORKUP_2_DRVNAT(pInterface)   ( (PDRVNAT)((uintptr_t)pInterface - RT_OFFSETOF(DRVNAT, INetworkUp)) )
    221221
    222222static DECLCALLBACK(void) drvNATSlowTimer(PPDMDRVINS pDrvIns, PTMTIMER pTimer, void *pvUser)
     
    293293    int rc = RTCritSectEnter(&pThis->csDevAccess);
    294294    AssertRC(rc);
    295     rc = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, RT_INDEFINITE_WAIT);
     295    rc = pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, RT_INDEFINITE_WAIT);
    296296    if (RT_SUCCESS(rc))
    297297    {
    298         rc = pThis->pPort->pfnReceive(pThis->pPort, pu8Buf, cb);
     298        rc = pThis->pIAboveNet->pfnReceive(pThis->pIAboveNet, pu8Buf, cb);
    299299        AssertRC(rc);
    300300    }
     
    336336    rc = RTCritSectEnter(&pThis->csDevAccess);
    337337
    338     rc = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, RT_INDEFINITE_WAIT);
     338    rc = pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, RT_INDEFINITE_WAIT);
    339339    if (RT_SUCCESS(rc))
    340340    {
    341         rc = pThis->pPort->pfnReceive(pThis->pPort, pu8Buf, cb);
     341        rc = pThis->pIAboveNet->pfnReceive(pThis->pIAboveNet, pu8Buf, cb);
    342342        AssertRC(rc);
    343343    }
     
    374374
    375375/**
    376  * Called by the guest to send data to the network.
    377  *
    378  * @returns VBox status code.
    379  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    380  * @param   pvBuf           Data to send.
    381  * @param   cb              Number of bytes to send.
    382  * @thread  EMT
    383  */
    384 static DECLCALLBACK(int) drvNATSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
    385 {
    386     PDRVNAT pThis = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface);
     376 * @interface_method_impl{PDMINETWORKUP,pfnSendDeprecated}
     377 */
     378static DECLCALLBACK(int) drvNATSendDeprecated(PPDMINETWORKUP pInterface, const void *pvBuf, size_t cb)
     379{
     380    PDRVNAT pThis = PDMINETWORKUP_2_DRVNAT(pInterface);
    387381
    388382    LogFlow(("drvNATSend: pvBuf=%p cb=%#x\n", pvBuf, cb));
     
    451445
    452446/**
    453  * Set promiscuous mode.
    454  *
    455  * This is called when the promiscuous mode is set. This means that there doesn't have
    456  * to be a mode change when it's called.
    457  *
    458  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    459  * @param   fPromiscuous    Set if the adaptor is now in promiscuous mode. Clear if it is not.
    460  * @thread  EMT
    461  */
    462 static DECLCALLBACK(void) drvNATSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
     447 * @interface_method_impl{PDMINETWORKUP,pfnSetPromiscuousMode}
     448 */
     449static DECLCALLBACK(void) drvNATSetPromiscuousMode(PPDMINETWORKUP pInterface, bool fPromiscuous)
    463450{
    464451    LogFlow(("drvNATSetPromiscuousMode: fPromiscuous=%d\n", fPromiscuous));
     
    500487 * @thread  EMT
    501488 */
    502 static DECLCALLBACK(void) drvNATNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
    503 {
    504     PDRVNAT pThis = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface);
     489static DECLCALLBACK(void) drvNATNotifyLinkChanged(PPDMINETWORKUP pInterface, PDMNETWORKLINKSTATE enmLinkState)
     490{
     491    PDRVNAT pThis = PDMINETWORKUP_2_DRVNAT(pInterface);
    505492
    506493    LogFlow(("drvNATNotifyLinkChanged: enmLinkState=%d\n", enmLinkState));
     
    815802
    816803    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    817     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONNECTOR, &pThis->INetworkConnector);
     804    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKUP, &pThis->INetworkUp);
    818805    return NULL;
    819806}
     
    827814static void drvNATSetMac(PDRVNAT pThis)
    828815{
    829     if (pThis->pConfig)
     816    if (pThis->pIAboveConfig)
    830817    {
    831818        RTMAC Mac;
    832         pThis->pConfig->pfnGetMac(pThis->pConfig, &Mac);
     819        pThis->pIAboveConfig->pfnGetMac(pThis->pIAboveConfig, &Mac);
    833820        /* Re-activate the port forwarding. If  */
    834821        slirp_set_ethaddr_and_activate_port_forwarding(pThis->pNATState, Mac.au8, pThis->GuestIP);
     
    998985    pDrvIns->IBase.pfnQueryInterface    = drvNATQueryInterface;
    999986    /* INetwork */
    1000     pThis->INetworkConnector.pfnSend               = drvNATSend;
    1001     pThis->INetworkConnector.pfnSetPromiscuousMode = drvNATSetPromiscuousMode;
    1002     pThis->INetworkConnector.pfnNotifyLinkChanged  = drvNATNotifyLinkChanged;
     987/** @todo implement the new INetworkUp interfaces. */
     988    pThis->INetworkUp.pfnSendDeprecated     = drvNATSendDeprecated;
     989    pThis->INetworkUp.pfnSetPromiscuousMode = drvNATSetPromiscuousMode;
     990    pThis->INetworkUp.pfnNotifyLinkChanged  = drvNATNotifyLinkChanged;
    1003991
    1004992    /*
     
    10251013     * Query the network port interface.
    10261014     */
    1027     pThis->pPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKPORT);
    1028     if (!pThis->pPort)
     1015    pThis->pIAboveNet = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKDOWN);
     1016    if (!pThis->pIAboveNet)
    10291017        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
    10301018                                N_("Configuration error: the above device/driver didn't "
    10311019                                "export the network port interface"));
    1032     pThis->pConfig = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKCONFIG);
    1033     if (!pThis->pConfig)
     1020    pThis->pIAboveConfig = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKCONFIG);
     1021    if (!pThis->pIAboveConfig)
    10341022        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
    10351023                                N_("Configuration error: the above device/driver didn't "
  • trunk/src/VBox/Devices/Network/DrvNetSniffer.cpp

    r26300 r26305  
    4848 * Block driver instance data.
    4949 *
    50  * @implements  PDMINETWORKCONNECTOR
    51  * @implements  PDMINETWORKPORT
     50 * @implements  PDMINETWORKUP
     51 * @implements  PDMINETWORKDOWN
    5252 * @implements  PDMINETWORKCONFIG
    5353 */
     
    5555{
    5656    /** The network interface. */
    57     PDMINETWORKCONNECTOR    INetworkConnector;
     57    PDMINETWORKUP           INetworkUp;
    5858    /** The network interface. */
    59     PDMINETWORKPORT         INetworkPort;
    60     /** The network config interface. */
     59    PDMINETWORKDOWN         INetworkDown;
     60    /** The network config interface.
     61     * @todo this is a main interface and shouldn't be here...  */
    6162    PDMINETWORKCONFIG       INetworkConfig;
    6263    /** The port we're attached to. */
    63     PPDMINETWORKPORT        pPort;
     64    PPDMINETWORKDOWN        pIAboveNet;
    6465    /** The config port interface we're attached to. */
    65     PPDMINETWORKCONFIG      pConfig;
     66    PPDMINETWORKCONFIG      pIAboveConfig;
    6667    /** The connector that's attached to us. */
    67     PPDMINETWORKCONNECTOR   pConnector;
     68    PPDMINETWORKUP          pIBelowNet;
    6869    /** The filename. */
    6970    char                    szFilename[RTPATH_MAX];
     
    7980} DRVNETSNIFFER, *PDRVNETSNIFFER;
    8081
    81 /** Converts a pointer to NAT::INetworkConnector to a PDRVNETSNIFFER. */
    82 #define PDMINETWORKCONNECTOR_2_DRVNETSNIFFER(pInterface)    ( (PDRVNETSNIFFER)((uintptr_t)pInterface - RT_OFFSETOF(DRVNETSNIFFER, INetworkConnector)) )
    83 
    84 /** Converts a pointer to NAT::INetworkPort to a PDRVNETSNIFFER. */
    85 #define PDMINETWORKPORT_2_DRVNETSNIFFER(pInterface)         ( (PDRVNETSNIFFER)((uintptr_t)pInterface - RT_OFFSETOF(DRVNETSNIFFER, INetworkPort)) )
    86 
    87 /** Converts a pointer to NAT::INetworkConfig to a PDRVNETSNIFFER. */
    88 #define PDMINETWORKCONFIG_2_DRVNETSNIFFER(pInterface)       ( (PDRVNETSNIFFER)((uintptr_t)pInterface - RT_OFFSETOF(DRVNETSNIFFER, INetworkConfig)) )
    89 
    90 
    91 
    92 /**
    93  * Send data to the network.
    94  *
    95  * @returns VBox status code.
    96  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    97  * @param   pvBuf           Data to send.
    98  * @param   cb              Number of bytes to send.
    99  * @thread  EMT
    100  */
    101 static DECLCALLBACK(int) drvNetSnifferSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
    102 {
    103     PDRVNETSNIFFER pThis = PDMINETWORKCONNECTOR_2_DRVNETSNIFFER(pInterface);
     82
     83
     84/**
     85 * @interface_method_impl{PDMINETWORKUP,pfnSendDeprecated}
     86 */
     87static DECLCALLBACK(int) drvNetSnifferSendDeprecated(PPDMINETWORKUP pInterface, const void *pvBuf, size_t cb)
     88{
     89    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkUp);
    10490
    10591    /* output to sniffer */
     
    10995
    11096    /* pass down */
    111     if (pThis->pConnector)
    112     {
    113         int rc = pThis->pConnector->pfnSend(pThis->pConnector, pvBuf, cb);
     97    if (pThis->pIBelowNet)
     98    {
     99        int rc = pThis->pIBelowNet->pfnSendDeprecated(pThis->pIBelowNet, pvBuf, cb);
    114100#if 0
    115101        RTCritSectEnter(&pThis->Lock);
     
    128114
    129115/**
    130  * Set promiscuous mode.
    131  *
    132  * This is called when the promiscuous mode is set. This means that there doesn't have
    133  * to be a mode change when it's called.
    134  *
    135  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    136  * @param   fPromiscuous    Set if the adaptor is now in promiscuous mode. Clear if it is not.
    137  * @thread  EMT
    138  */
    139 static DECLCALLBACK(void) drvNetSnifferSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
     116 * @interface_method_impl{PDMINETWORKUP,pfnSetPromiscuousMode}
     117 */
     118static DECLCALLBACK(void) drvNetSnifferSetPromiscuousMode(PPDMINETWORKUP pInterface, bool fPromiscuous)
    140119{
    141120    LogFlow(("drvNetSnifferSetPromiscuousMode: fPromiscuous=%d\n", fPromiscuous));
    142     PDRVNETSNIFFER pThis = PDMINETWORKCONNECTOR_2_DRVNETSNIFFER(pInterface);
    143     if (pThis->pConnector)
    144         pThis->pConnector->pfnSetPromiscuousMode(pThis->pConnector, fPromiscuous);
    145 }
    146 
    147 
    148 /**
    149  * Notification on link status changes.
    150  *
    151  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    152  * @param   enmLinkState    The new link state.
    153  * @thread  EMT
    154  */
    155 static DECLCALLBACK(void) drvNetSnifferNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
     121    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkUp);
     122    if (pThis->pIBelowNet)
     123        pThis->pIBelowNet->pfnSetPromiscuousMode(pThis->pIBelowNet, fPromiscuous);
     124}
     125
     126
     127/**
     128 * @interface_method_impl{PDMINETWORKUP,pfnNotifyLinkChanged}
     129 */
     130static DECLCALLBACK(void) drvNetSnifferNotifyLinkChanged(PPDMINETWORKUP pInterface, PDMNETWORKLINKSTATE enmLinkState)
    156131{
    157132    LogFlow(("drvNetSnifferNotifyLinkChanged: enmLinkState=%d\n", enmLinkState));
    158     PDRVNETSNIFFER pThis = PDMINETWORKCONNECTOR_2_DRVNETSNIFFER(pInterface);
    159     if (pThis->pConnector)
    160         pThis->pConnector->pfnNotifyLinkChanged(pThis->pConnector, enmLinkState);
     133    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkUp);
     134    if (pThis->pIBelowNet)
     135        pThis->pIBelowNet->pfnNotifyLinkChanged(pThis->pIBelowNet, enmLinkState);
    161136}
    162137
     
    170145 * @thread  EMT
    171146 */
    172 static DECLCALLBACK(int) drvNetSnifferWaitReceiveAvail(PPDMINETWORKPORT pInterface, RTMSINTERVAL cMillies)
    173 {
    174     PDRVNETSNIFFER pThis = PDMINETWORKPORT_2_DRVNETSNIFFER(pInterface);
    175     return pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, cMillies);
     147static DECLCALLBACK(int) drvNetSnifferWaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
     148{
     149    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkDown);
     150    return pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, cMillies);
    176151}
    177152
     
    186161 * @thread  EMT
    187162 */
    188 static DECLCALLBACK(int) drvNetSnifferReceive(PPDMINETWORKPORT pInterface, const void *pvBuf, size_t cb)
    189 {
    190     PDRVNETSNIFFER pThis = PDMINETWORKPORT_2_DRVNETSNIFFER(pInterface);
     163static DECLCALLBACK(int) drvNetSnifferReceive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb)
     164{
     165    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkDown);
    191166
    192167    /* output to sniffer */
     
    196171
    197172    /* pass up */
    198     int rc = pThis->pPort->pfnReceive(pThis->pPort, pvBuf, cb);
     173    int rc = pThis->pIAboveNet->pfnReceive(pThis->pIAboveNet, pvBuf, cb);
    199174#if 0
    200175    RTCritSectEnter(&pThis->Lock);
     
    220195static DECLCALLBACK(int) drvNetSnifferGetMac(PPDMINETWORKCONFIG pInterface, PRTMAC pMac)
    221196{
    222     PDRVNETSNIFFER pThis = PDMINETWORKCONFIG_2_DRVNETSNIFFER(pInterface);
    223     return pThis->pConfig->pfnGetMac(pThis->pConfig, pMac);
     197    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkConfig);
     198    return pThis->pIAboveConfig->pfnGetMac(pThis->pIAboveConfig, pMac);
    224199}
    225200
     
    233208static DECLCALLBACK(PDMNETWORKLINKSTATE) drvNetSnifferGetLinkState(PPDMINETWORKCONFIG pInterface)
    234209{
    235     PDRVNETSNIFFER pThis = PDMINETWORKCONFIG_2_DRVNETSNIFFER(pInterface);
    236     return pThis->pConfig->pfnGetLinkState(pThis->pConfig);
     210    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkConfig);
     211    return pThis->pIAboveConfig->pfnGetLinkState(pThis->pIAboveConfig);
    237212}
    238213
     
    247222static DECLCALLBACK(int) drvNetSnifferSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState)
    248223{
    249     PDRVNETSNIFFER pThis = PDMINETWORKCONFIG_2_DRVNETSNIFFER(pInterface);
    250     return pThis->pConfig->pfnSetLinkState(pThis->pConfig, enmState);
     224    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkConfig);
     225    return pThis->pIAboveConfig->pfnSetLinkState(pThis->pIAboveConfig, enmState);
    251226}
    252227
     
    260235    PDRVNETSNIFFER  pThis   = PDMINS_2_DATA(pDrvIns, PDRVNETSNIFFER);
    261236    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    262     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONNECTOR, &pThis->INetworkConnector);
    263     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKPORT, &pThis->INetworkPort);
     237    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKUP, &pThis->INetworkUp);
     238    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown);
    264239    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONFIG, &pThis->INetworkConfig);
    265240    return NULL;
     
    279254    LogFlow(("drvNetSnifferDetach: pDrvIns: %p, fFlags: %u\n", pDrvIns, fFlags));
    280255
    281     pThis->pConnector = NULL;
     256    pThis->pIBelowNet = NULL;
    282257}
    283258
     
    302277    int rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pBaseDown);
    303278    if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    304         pThis->pConnector = NULL;
     279        pThis->pIBelowNet = NULL;
    305280    else if (RT_SUCCESS(rc))
    306281    {
    307         pThis->pConnector = PDMIBASE_QUERY_INTERFACE(pBaseDown, PDMINETWORKCONNECTOR);
    308         if (!pThis->pConnector)
     282        pThis->pIBelowNet = PDMIBASE_QUERY_INTERFACE(pBaseDown, PDMINETWORKUP);
     283        if (!pThis->pIBelowNet)
    309284        {
    310285            AssertMsgFailed(("Configuration error: the driver below didn't export the network connector interface!\n"));
     
    369344     * Init the static parts.
    370345     */
    371     pThis->pDrvIns                      = pDrvIns;
    372     pThis->File                         = NIL_RTFILE;
     346    pThis->pDrvIns                                  = pDrvIns;
     347    pThis->File                                     = NIL_RTFILE;
    373348    /* The pcap file *must* start at time offset 0,0. */
    374     pThis->StartNanoTS                  = RTTimeNanoTS() - RTTimeProgramNanoTS();
     349    pThis->StartNanoTS                              = RTTimeNanoTS() - RTTimeProgramNanoTS();
    375350    /* IBase */
    376     pDrvIns->IBase.pfnQueryInterface    = drvNetSnifferQueryInterface;
    377     /* INetworkConnector */
    378     pThis->INetworkConnector.pfnSend                = drvNetSnifferSend;
    379     pThis->INetworkConnector.pfnSetPromiscuousMode  = drvNetSnifferSetPromiscuousMode;
    380     pThis->INetworkConnector.pfnNotifyLinkChanged   = drvNetSnifferNotifyLinkChanged;
    381     /* INetworkPort */
    382     pThis->INetworkPort.pfnWaitReceiveAvail         = drvNetSnifferWaitReceiveAvail;
    383     pThis->INetworkPort.pfnReceive                  = drvNetSnifferReceive;
     351    pDrvIns->IBase.pfnQueryInterface                = drvNetSnifferQueryInterface;
     352    /* INetworkUp */
     353    pThis->INetworkUp.pfnSendDeprecated             = drvNetSnifferSendDeprecated;
     354    pThis->INetworkUp.pfnSetPromiscuousMode         = drvNetSnifferSetPromiscuousMode;
     355    pThis->INetworkUp.pfnNotifyLinkChanged          = drvNetSnifferNotifyLinkChanged;
     356/** @todo implement the new interfaces methods! */
     357    /* INetworkDown */
     358    pThis->INetworkDown.pfnWaitReceiveAvail         = drvNetSnifferWaitReceiveAvail;
     359    pThis->INetworkDown.pfnReceive                  = drvNetSnifferReceive;
    384360    /* INetworkConfig */
    385361    pThis->INetworkConfig.pfnGetMac                 = drvNetSnifferGetMac;
     
    408384     * Query the network port interface.
    409385     */
    410     pThis->pPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKPORT);
    411     if (!pThis->pPort)
     386    pThis->pIAboveNet = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKDOWN);
     387    if (!pThis->pIAboveNet)
    412388    {
    413389        AssertMsgFailed(("Configuration error: the above device/driver didn't export the network port interface!\n"));
     
    418394     * Query the network config interface.
    419395     */
    420     pThis->pConfig = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKCONFIG);
    421     if (!pThis->pConfig)
     396    pThis->pIAboveConfig = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKCONFIG);
     397    if (!pThis->pIAboveConfig)
    422398    {
    423399        AssertMsgFailed(("Configuration error: the above device/driver didn't export the network config interface!\n"));
     
    431407    rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pBaseDown);
    432408    if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    433         pThis->pConnector = NULL;
     409        pThis->pIBelowNet = NULL;
    434410    else if (RT_SUCCESS(rc))
    435411    {
    436         pThis->pConnector = PDMIBASE_QUERY_INTERFACE(pBaseDown, PDMINETWORKCONNECTOR);
    437         if (!pThis->pConnector)
     412        pThis->pIBelowNet = PDMIBASE_QUERY_INTERFACE(pBaseDown, PDMINETWORKUP);
     413        if (!pThis->pIBelowNet)
    438414        {
    439415            AssertMsgFailed(("Configuration error: the driver below didn't export the network connector interface!\n"));
  • trunk/src/VBox/Devices/Network/DrvTAP.cpp

    r26300 r26305  
    8484 * TAP driver instance data.
    8585 *
    86  * @implements PDMINETWORKCONNECTOR
     86 * @implements PDMINETWORKUP
    8787 */
    8888typedef struct DRVTAP
    8989{
    9090    /** The network interface. */
    91     PDMINETWORKCONNECTOR    INetworkConnector;
     91    PDMINETWORKUP           INetworkUp;
    9292    /** The network interface. */
    93     PPDMINETWORKPORT        pPort;
     93    PPDMINETWORKDOWN        pIAboveNet;
    9494    /** Pointer to the driver instance. */
    9595    PPDMDRVINS              pDrvIns;
     
    146146
    147147
    148 /** Converts a pointer to TAP::INetworkConnector to a PRDVTAP. */
    149 #define PDMINETWORKCONNECTOR_2_DRVTAP(pInterface) ( (PDRVTAP)((uintptr_t)pInterface - RT_OFFSETOF(DRVTAP, INetworkConnector)) )
     148/** Converts a pointer to TAP::INetworkUp to a PRDVTAP. */
     149#define PDMINETWORKUP_2_DRVTAP(pInterface) ( (PDRVTAP)((uintptr_t)pInterface - RT_OFFSETOF(DRVTAP, INetworkUp)) )
    150150
    151151
     
    164164
    165165/**
    166  * Send data to the network.
    167  *
    168  * @returns VBox status code.
    169  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    170  * @param   pvBuf           Data to send.
    171  * @param   cb              Number of bytes to send.
    172  * @thread  EMT
    173  */
    174 static DECLCALLBACK(int) drvTAPSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
    175 {
    176     PDRVTAP pThis = PDMINETWORKCONNECTOR_2_DRVTAP(pInterface);
     166 * @interface_method_impl{PDMINETWORKUP,pfnSendDeprecated}
     167 */
     168static DECLCALLBACK(int) drvTAPSendDeprecated(PPDMINETWORKUP pInterface, const void *pvBuf, size_t cb)
     169{
     170    PDRVTAP pThis = PDMINETWORKUP_2_DRVTAP(pInterface);
    177171    STAM_COUNTER_INC(&pThis->StatPktSent);
    178172    STAM_COUNTER_ADD(&pThis->StatPktSentBytes, cb);
     
    198192
    199193/**
    200  * Set promiscuous mode.
    201  *
    202  * This is called when the promiscuous mode is set. This means that there doesn't have
    203  * to be a mode change when it's called.
    204  *
    205  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    206  * @param   fPromiscuous    Set if the adaptor is now in promiscuous mode. Clear if it is not.
    207  * @thread  EMT
    208  */
    209 static DECLCALLBACK(void) drvTAPSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
     194 * @interface_method_impl{PDMINETWORKUP,pfnSetPromiscuousMode}
     195 */
     196static DECLCALLBACK(void) drvTAPSetPromiscuousMode(PPDMINETWORKUP pInterface, bool fPromiscuous)
    210197{
    211198    LogFlow(("drvTAPSetPromiscuousMode: fPromiscuous=%d\n", fPromiscuous));
     
    221208 * @thread  EMT
    222209 */
    223 static DECLCALLBACK(void) drvTAPNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
     210static DECLCALLBACK(void) drvTAPNotifyLinkChanged(PPDMINETWORKUP pInterface, PDMNETWORKLINKSTATE enmLinkState)
    224211{
    225212    LogFlow(("drvNATNotifyLinkChanged: enmLinkState=%d\n", enmLinkState));
     
    304291                 */
    305292                STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
    306                 int rc1 = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, RT_INDEFINITE_WAIT);
     293                int rc1 = pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, RT_INDEFINITE_WAIT);
    307294                STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
    308295
     
    326313                STAM_COUNTER_INC(&pThis->StatPktRecv);
    327314                STAM_COUNTER_ADD(&pThis->StatPktRecvBytes, cbRead);
    328                 rc1 = pThis->pPort->pfnReceive(pThis->pPort, achBuf, cbRead);
     315                rc1 = pThis->pIAboveNet->pfnReceive(pThis->pIAboveNet, achBuf, cbRead);
    329316                AssertRC(rc1);
    330317            }
     
    787774
    788775    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    789     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONNECTOR, &pThis->INetworkConnector);
     776    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKUP, &pThis->INetworkUp);
    790777    return NULL;
    791778}
     
    905892    pDrvIns->IBase.pfnQueryInterface    = drvTAPQueryInterface;
    906893    /* INetwork */
    907     pThis->INetworkConnector.pfnSend                = drvTAPSend;
    908     pThis->INetworkConnector.pfnSetPromiscuousMode  = drvTAPSetPromiscuousMode;
    909     pThis->INetworkConnector.pfnNotifyLinkChanged   = drvTAPNotifyLinkChanged;
     894/** @todo implement the new INetworkUp interfaces. */
     895    pThis->INetworkUp.pfnSendDeprecated         = drvTAPSendDeprecated;
     896    pThis->INetworkUp.pfnSetPromiscuousMode     = drvTAPSetPromiscuousMode;
     897    pThis->INetworkUp.pfnNotifyLinkChanged      = drvTAPNotifyLinkChanged;
    910898
    911899    /*
     
    925913     * Query the network port interface.
    926914     */
    927     pThis->pPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKPORT);
    928     if (!pThis->pPort)
     915    pThis->pIAboveNet = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKDOWN);
     916    if (!pThis->pIAboveNet)
    929917        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
    930918                                N_("Configuration error: The above device/driver didn't export the network port interface"));
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r26222 r26305  
    402402    GEN_CHECK_OFF(PCNetState, pDrvBase);
    403403    GEN_CHECK_OFF(PCNetState, IBase);
    404     GEN_CHECK_OFF(PCNetState, INetworkPort);
     404    GEN_CHECK_OFF(PCNetState, INetworkDown);
    405405    GEN_CHECK_OFF(PCNetState, INetworkConfig);
    406406    GEN_CHECK_OFF(PCNetState, MMIOBase);
     
    12651265    GEN_CHECK_SIZE(E1KSTATE);
    12661266    GEN_CHECK_OFF(E1KSTATE, IBase);
    1267     GEN_CHECK_OFF(E1KSTATE, INetworkPort);
     1267    GEN_CHECK_OFF(E1KSTATE, INetworkDown);
    12681268    GEN_CHECK_OFF(E1KSTATE, INetworkConfig);
    12691269    GEN_CHECK_OFF(E1KSTATE, ILeds);
     
    13571357    GEN_CHECK_OFF(VPCISTATE, Queues[VIRTIO_MAX_NQUEUES]);
    13581358    GEN_CHECK_OFF(VNETSTATE, VPCI);
    1359     GEN_CHECK_OFF(VNETSTATE, INetworkPort);
     1359    GEN_CHECK_OFF(VNETSTATE, INetworkDown);
    13601360    GEN_CHECK_OFF(VNETSTATE, INetworkConfig);
    13611361    GEN_CHECK_OFF(VNETSTATE, pDrvBase);
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