VirtualBox

Changeset 29491 in vbox for trunk


Ignore:
Timestamp:
May 14, 2010 5:46:22 PM (15 years ago)
Author:
vboxsync
Message:

IntNet: added MAC address notification and connect/disconnect interface callbacks.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/intnet.h

    r28830 r29491  
    648648
    649649    /**
     650     * Notifies when the MAC address of an interface is set or changes.
     651     *
     652     * @param   pIfPort     Pointer to this structure.
     653     * @param   hIf         The handle of the network interface.
     654     * @param   pMac        Pointer to the MAC address of the connecting VM NIC.
     655     */
     656    DECLR0CALLBACKMEMBER(void, pfnNotifyMacAddress,(PINTNETTRUNKIFPORT pIfPort, INTNETIFHANDLE hIf, PCRTMAC pMac));
     657
     658    /**
     659     * Called when an interface is connected to the network.
     660     *
     661     * @returns IPRT status code.
     662     * @param   pIfPort     Pointer to this structure.
     663     * @param   hIf         The handle of the network interface.
     664     */
     665    DECLR0CALLBACKMEMBER(int, pfnConnectInterface,(PINTNETTRUNKIFPORT pIfPort, INTNETIFHANDLE hIf));
     666
     667    /**
     668     * Called when an interface is disconnected from the network.
     669     *
     670     * @returns IPRT status code.
     671     * @param   pIfPort     Pointer to this structure.
     672     * @param   hIf         The handle of the network interface.
     673     */
     674    DECLR0CALLBACKMEMBER(int, pfnDisconnectInterface,(PINTNETTRUNKIFPORT pIfPort, INTNETIFHANDLE hIf));
     675
     676    /**
    650677     * Waits for the interface to become idle.
    651678     *
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r29362 r29491  
    36223622        }
    36233623
     3624        PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
    36243625        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3626        if (pTrunk && pTrunk->pIfPort)
     3627        {
     3628            Log(("IntNetR0IfSetMacAddress: pfnNotifyMacAddress hIf=%RX32\n", hIf));
     3629            pTrunk->pIfPort->pfnNotifyMacAddress(pTrunk->pIfPort, hIf, pMac);
     3630        }
    36253631    }
    36263632    else
     
    39643970    ASMAtomicWriteBool(&pIf->fDestroying, true);
    39653971
     3972    PINTNETNETWORK pNetwork = pIf->pNetwork;
     3973    PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
     3974    if (pTrunk && pTrunk->pIfPort)
     3975    {
     3976        Log(("intnetR0IfDestruct: pfnDisconnectInterface hIf=%RX32\n", pIf->hIf));
     3977        pTrunk->pIfPort->pfnDisconnectInterface(pTrunk->pIfPort, pIf->hIf);
     3978    }
     3979
    39663980    /*
    39673981     * Delete the interface handle so the object no longer can be used.
     
    39793993     * of cleanup order we might have been orphaned by the network destructor.
    39803994     */
    3981     PINTNETNETWORK pNetwork = pIf->pNetwork;
    39823995    if (pNetwork)
    39833996    {
     
    40794092        intnetR0IfAddrCacheDestroy(&pIf->aAddrCache[i]);
    40804093
    4081      pIf->pvObj = NULL;
     4094    pIf->pvObj = NULL;
    40824095    RTMemFree(pIf);
    40834096}
     
    42004213                    pNetwork->MacTab.cEntries = iIf + 1;
    42014214                    pIf->pNetwork = pNetwork;
     4215
     4216                    /** @todo handle failure of pfnConnectInterface */
     4217                    PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
     4218                    if (pTrunk && pTrunk->pIfPort)
     4219                    {
     4220                        Log(("intnetR0NetworkCreateIf: pfnConnectInterface hIf=%RX32\n", pIf->hIf));
     4221                        pTrunk->pIfPort->pfnConnectInterface(pTrunk->pIfPort, pIf->hIf);
     4222                    }
    42024223
    42034224                    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c

    r29464 r29491  
    535535
    536536/**
     537 * @copydoc INTNETTRUNKIFPORT::pfnNotifyMacAddress
     538 */
     539static DECLCALLBACK(void) vboxNetFltPortNotifyMacAddress(PINTNETTRUNKIFPORT pIfPort, INTNETIFHANDLE hIf, PCRTMAC pMac)
     540{
     541    PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);
     542
     543    /*
     544     * Input validation.
     545     */
     546    AssertPtr(pThis);
     547    AssertPtr(pSG);
     548    Assert(pThis->MyPort.u32Version == INTNETTRUNKIFPORT_VERSION);
     549
     550    vboxNetFltRetain(pThis, false /* fBusy */);
     551    vboxNetFltPortOsNotifyMacAddress(pThis, hIf, pMac);
     552    vboxNetFltRelease(pThis, false /* fBusy */);
     553}
     554
     555
     556/**
     557 * @copydoc INTNETTRUNKIFPORT::pfnConnectInterface
     558 */
     559static DECLCALLBACK(int) vboxNetFltPortConnectInterface(PINTNETTRUNKIFPORT pIfPort,  INTNETIFHANDLE hIf)
     560{
     561    PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);
     562    int rc = VINF_SUCCESS;
     563
     564    /*
     565     * Input validation.
     566     */
     567    AssertPtr(pThis);
     568    AssertPtr(pSG);
     569    Assert(pThis->MyPort.u32Version == INTNETTRUNKIFPORT_VERSION);
     570
     571    vboxNetFltRetain(pThis, false /* fBusy */);
     572    rc = vboxNetFltPortOsConnectInterface(pThis, hIf);
     573    vboxNetFltRelease(pThis, false /* fBusy */);
     574
     575    return rc;
     576}
     577
     578
     579/**
     580 * @copydoc INTNETTRUNKIFPORT::pfnDisconnectInterface
     581 */
     582static DECLCALLBACK(int) vboxNetFltPortDisconnectInterface(PINTNETTRUNKIFPORT pIfPort, INTNETIFHANDLE hIf)
     583{
     584    PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);
     585    int rc = VINF_SUCCESS;
     586
     587    /*
     588     * Input validation.
     589     */
     590    AssertPtr(pThis);
     591    AssertPtr(pSG);
     592    Assert(pThis->MyPort.u32Version == INTNETTRUNKIFPORT_VERSION);
     593
     594    vboxNetFltRetain(pThis, false /* fBusy */);
     595    rc = vboxNetFltPortOsDisconnectInterface(pThis, hIf);
     596    vboxNetFltRelease(pThis, false /* fBusy */);
     597
     598    return rc;
     599}
     600
     601
     602/**
    537603 * @copydoc INTNETTRUNKIFPORT::pfnDisconnectAndRelease
    538604 */
     
    933999    pNew->MyPort.pfnWaitForIdle         = vboxNetFltPortWaitForIdle;
    9341000    pNew->MyPort.pfnXmit                = vboxNetFltPortXmit;
     1001    pNew->MyPort.pfnNotifyMacAddress    = vboxNetFltPortNotifyMacAddress;
     1002    pNew->MyPort.pfnConnectInterface    = vboxNetFltPortConnectInterface;
     1003    pNew->MyPort.pfnDisconnectInterface = vboxNetFltPortDisconnectInterface;   
    9351004    pNew->MyPort.u32VersionEnd          = INTNETTRUNKIFPORT_VERSION;
    9361005    pNew->pSwitchPort                   = pSwitchPort;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h

    r29108 r29491  
    380380
    381381/**
     382 * This is called when a network interface has obtained a new MAC address.
     383 *
     384 * @param   pThis           The instance.
     385 * @param   hIf             The handle to the network.
     386 * @param   pMac            Pointer to the new MAC address.
     387 */
     388DECLHIDDEN(void) vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf, PCRTMAC pMac);
     389
     390/**
     391 * This is called when an interface is connected to the network.
     392 *
     393 * @return IPRT status code.
     394 * @param   pThis           The instance.
     395 * @param   hIf             The handle to the network.
     396 */
     397DECLHIDDEN(int) vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf);
     398
     399/**
     400 * This is called when a VM host disconnects from the network.
     401 *
     402 * @param   pThis           The instance.
     403 * @param   hIf             The handle to the network.
     404 */
     405DECLHIDDEN(int) vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf);
     406
     407/**
    382408 * This is called to when disconnecting from a network.
    383409 *
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r28830 r29491  
    11911191}
    11921192
     1193
     1194void vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf, PCRTMAC pMac)
     1195{
     1196    NOREF(pThis); NOREF(hIf); NOREF(pMac);
     1197}
     1198
     1199
     1200int vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     1201{
     1202    /* Nothing to do */
     1203    NOREF(pThis); NOREF(hIf);
     1204    return VINF_SUCCESS;
     1205}
     1206
     1207
     1208int vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     1209{
     1210    /* Nothing to do */
     1211    NOREF(pThis); NOREF(hIf);
     1212    return VINF_SUCCESS;
     1213}
     1214
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c

    r28830 r29491  
    745745    return VINF_SUCCESS;
    746746}
     747
     748void vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf, PCRTMAC pMac)
     749{
     750    NOREF(pThis); NOREF(hIf); NOREF(pMac);
     751}
     752
     753int vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     754{
     755    /* Nothing to do */
     756    NOREF(pThis); NOREF(hIf);
     757    return VINF_SUCCESS;
     758}
     759
     760int vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     761{
     762    /* Nothing to do */
     763    NOREF(pThis); NOREF(hIf);
     764    return VINF_SUCCESS;
     765}
     766
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r28830 r29491  
    17651765}
    17661766
     1767
     1768void vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf, PCRTMAC pMac)
     1769{
     1770    NOREF(pThis); NOREF(hIf); NOREF(pMac);
     1771}
     1772
     1773
     1774int vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     1775{
     1776    /* Nothing to do */
     1777    NOREF(pThis); NOREF(hIf);
     1778    return VINF_SUCCESS;
     1779}
     1780
     1781
     1782int vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     1783{
     1784    /* Nothing to do */
     1785    NOREF(pThis); NOREF(hIf);
     1786    return VINF_SUCCESS;
     1787}
     1788
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c

    r28961 r29491  
    37053705
    37063706
     3707void vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf, PCRTMAC pMac)
     3708{
     3709    NOREF(pThis); NOREF(hIf); NOREF(pMac);
     3710}
     3711
     3712
     3713int vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     3714{
     3715    /* Nothing to do */
     3716    NOREF(pThis); NOREF(hIf);
     3717    return VINF_SUCCESS;
     3718}
     3719
     3720
     3721int vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     3722{
     3723    /* Nothing to do */
     3724    NOREF(pThis); NOREF(hIf);
     3725    return VINF_SUCCESS;
     3726}
     3727
     3728
    37073729int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, PINTNETSG pSG, uint32_t fDst)
    37083730{
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFltBow-solaris.c

    r29469 r29491  
    10941094}
    10951095
     1096
     1097void vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf, PCRTMAC pMac)
     1098{
     1099    LogRel((DEVICE_NAME ":vboxNetFltPortOSNotifyMacAddress %s %.6Rhxs\n", pThis->szName, pMac));
     1100}
     1101
     1102
     1103int vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     1104{
     1105    LogRel((DEVICE_NAME ":vboxNetFltPortOsConnectInterface\n"));
     1106    return VINF_SUCCESS;
     1107}
     1108
     1109
     1110int vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     1111{
     1112    LogRel((DEVICE_NAME ":vboxNetFltPortOsDisconnectInterface\n"));
     1113    return VINF_SUCCESS;
     1114}
     1115
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFlt-win.c

    r29464 r29491  
    37773777}
    37783778
     3779void vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf, PCRTMAC pMac)
     3780{
     3781    NOREF(pThis); NOREF(hIf); NOREF(pMac);
     3782}
     3783
     3784int vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     3785{
     3786    /* Nothing to do */
     3787    NOREF(pThis); NOREF(hIf);
     3788    return VINF_SUCCESS;
     3789}
     3790
     3791int vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, INTNETIFHANDLE hIf)
     3792{
     3793    /* Nothing to do */
     3794    NOREF(pThis); NOREF(hIf);
     3795    return VINF_SUCCESS;
     3796}
     3797
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