VirtualBox

Changeset 36023 in vbox


Ignore:
Timestamp:
Feb 18, 2011 3:01:20 PM (14 years ago)
Author:
vboxsync
Message:

DevINIP: Make it work again after the network overhaul.

File:
1 edited

Legend:

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

    r35353 r36023  
    7575    /** The network port this device provides (LUN\#0). */
    7676    PDMINETWORKDOWN         INetworkDown;
     77    /** Tzhe network configuration port this device provides (LUN\#0). */
     78    PDMINETWORKCONFIG       INetworkConfig;
    7779    /** The base interface of the network driver below us. */
    7880    PPDMIBASE               pDrvBase;
     
    102104     * provides a proper interface to all IP stack functions. */
    103105    const void             *pLinkHack;
     106    /** Flag whether the link is up. */
     107    bool                    fLnkUp;
    104108} DEVINTNETIP, *PDEVINTNETIP;
    105109
     
    226230    {
    227231        PPDMSCATTERGATHER pSgBuf;
     232
     233        rc = g_pDevINIPData->pDrv->pfnBeginXmit(g_pDevINIPData->pDrv, true /* fOnWorkerThread */);
     234        if (RT_FAILURE(rc))
     235            return ERR_IF;
     236
    228237        rc = g_pDevINIPData->pDrv->pfnAllocBuf(g_pDevINIPData->pDrv, DEVINIP_MAX_FRAME, NULL /*pGso*/, &pSgBuf);
    229238        if (RT_SUCCESS(rc))
     
    253262            }
    254263            if (cbBuf)
    255                 rc = g_pDevINIPData->pDrv->pfnSendBuf(g_pDevINIPData->pDrv, pSgBuf, false);
     264            {
     265                pSgBuf->cbUsed = cbBuf;
     266                rc = g_pDevINIPData->pDrv->pfnSendBuf(g_pDevINIPData->pDrv, pSgBuf, true /* fOnWorkerThread */);
     267            }
    256268            else
    257269                rc = g_pDevINIPData->pDrv->pfnFreeBuf(g_pDevINIPData->pDrv, pSgBuf);
     
    261273#endif
    262274        }
     275
     276        g_pDevINIPData->pDrv->pfnEndXmit(g_pDevINIPData->pDrv);
    263277    }
    264278
     
    400414}
    401415
     416
     417/**
     418 * Gets the current Media Access Control (MAC) address.
     419 *
     420 * @returns VBox status code.
     421 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     422 * @param   pMac            Where to store the MAC address.
     423 * @thread  EMT
     424 */
     425static DECLCALLBACK(int) devINIPGetMac(PPDMINETWORKCONFIG pInterface, PRTMAC pMac)
     426{
     427    PDEVINTNETIP pThis = RT_FROM_MEMBER(pInterface, DEVINTNETIP, INetworkConfig);
     428    memcpy(pMac, pThis->MAC.au8, sizeof(RTMAC));
     429    return VINF_SUCCESS;
     430}
     431
     432/**
     433 * Gets the new link state.
     434 *
     435 * @returns The current link state.
     436 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     437 * @thread  EMT
     438 */
     439static DECLCALLBACK(PDMNETWORKLINKSTATE) devINIPGetLinkState(PPDMINETWORKCONFIG pInterface)
     440{
     441    PDEVINTNETIP pThis = RT_FROM_MEMBER(pInterface, DEVINTNETIP, INetworkConfig);
     442    if (pThis->fLnkUp)
     443        return PDMNETWORKLINKSTATE_UP;
     444    return PDMNETWORKLINKSTATE_DOWN;
     445}
     446
     447
     448/**
     449 * Sets the new link state.
     450 *
     451 * @returns VBox status code.
     452 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     453 * @param   enmState        The new link state
     454 */
     455static DECLCALLBACK(int) devINIPSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState)
     456{
     457    PDEVINTNETIP pThis = RT_FROM_MEMBER(pInterface, DEVINTNETIP, INetworkConfig);
     458    bool fNewUp = enmState == PDMNETWORKLINKSTATE_UP;
     459
     460    if (fNewUp != pThis->fLnkUp)
     461    {
     462        if (fNewUp)
     463        {
     464            LogFlowFunc(("Link is up\n"));
     465            pThis->fLnkUp = true;
     466        }
     467        else
     468        {
     469            LogFlowFunc(("Link is down\n"));
     470            pThis->fLnkUp = false;
     471        }
     472        if (pThis->pDrv)
     473            pThis->pDrv->pfnNotifyLinkChanged(pThis->pDrv, enmState);
     474    }
     475    return VINF_SUCCESS;
     476}
     477
    402478/* -=-=-=-=- PDMIBASE -=-=-=-=- */
    403479
     
    411487    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    412488    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown);
     489    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONFIG, &pThis->INetworkConfig);
    413490    return NULL;
    414491}
     
    491568    pThis->INetworkDown.pfnReceive          = devINIPNetworkDown_Input;
    492569    pThis->INetworkDown.pfnXmitPending      = devINIPNetworkDown_XmitPending;
     570    /* INetworkConfig */
     571    pThis->INetworkConfig.pfnGetMac         = devINIPGetMac;
     572    pThis->INetworkConfig.pfnGetLinkState   = devINIPGetLinkState;
     573    pThis->INetworkConfig.pfnSetLinkState   = devINIPSetLinkState;
    493574
    494575    /*
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