VirtualBox

Changeset 58093 in vbox for trunk


Ignore:
Timestamp:
Oct 7, 2015 1:54:00 PM (9 years ago)
Author:
vboxsync
Message:

VBoxNetAdp/darwin: use ether_add_proto/ether_del_proto. We must use
them so that when we call ether_demux it does the right thing for
registered protocols.

Location:
trunk/src/VBox/HostDrivers/VBoxNetAdp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h

    r57907 r58093  
    102102            /** MAC address. */
    103103            RTMAC             Mac;
    104             /** Protocol families attached to this adapter. */
    105             protocol_family_t aAttachedFamilies[VBOXNETADP_MAX_FAMILIES];
    106104            /** @} */
    107105# elif defined(RT_OS_LINUX)
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp

    r58070 r58093  
    156156    mbuf_freem_list(pMBuf);
    157157    return 0;
    158 }
    159 
    160 static void vboxNetAdpDarwinAttachFamily(PVBOXNETADP pThis, protocol_family_t Family)
    161 {
    162     u_int32_t i;
    163     for (i = 0; i < VBOXNETADP_MAX_FAMILIES; i++)
    164         if (pThis->u.s.aAttachedFamilies[i] == 0)
    165         {
    166             pThis->u.s.aAttachedFamilies[i] = Family;
    167             break;
    168         }
    169 }
    170 
    171 static void vboxNetAdpDarwinDetachFamily(PVBOXNETADP pThis, protocol_family_t Family)
    172 {
    173     u_int32_t i;
    174     for (i = 0; i < VBOXNETADP_MAX_FAMILIES; i++)
    175         if (pThis->u.s.aAttachedFamilies[i] == Family)
    176             pThis->u.s.aAttachedFamilies[i] = 0;
    177 }
    178 
    179 static errno_t vboxNetAdpDarwinAddProto(ifnet_t pIface, protocol_family_t Family, const struct ifnet_demux_desc *pDemuxDesc, u_int32_t nDesc)
    180 {
    181     PVBOXNETADP pThis = VBOXNETADP_FROM_IFACE(pIface);
    182     Assert(pThis);
    183     vboxNetAdpDarwinAttachFamily(pThis, Family);
    184     LogFlow(("vboxNetAdpAddProto: Family=%d.\n", Family));
    185     return ether_add_proto(pIface, Family, pDemuxDesc, nDesc);
    186 }
    187 
    188 static errno_t vboxNetAdpDarwinDelProto(ifnet_t pIface, protocol_family_t Family)
    189 {
    190     PVBOXNETADP pThis = VBOXNETADP_FROM_IFACE(pIface);
    191     Assert(pThis);
    192     LogFlow(("vboxNetAdpDelProto: Family=%d.\n", Family));
    193     vboxNetAdpDarwinDetachFamily(pThis, Family);
    194     return ether_del_proto(pIface, Family);
    195158}
    196159
     
    295258    Params.output = vboxNetAdpDarwinOutput;
    296259    Params.demux = vboxNetAdpDarwinDemux;
    297     Params.add_proto = vboxNetAdpDarwinAddProto;
    298     Params.del_proto = vboxNetAdpDarwinDelProto;
     260    Params.add_proto = ether_add_proto;
     261    Params.del_proto = ether_del_proto;
    299262    Params.check_multi = ether_check_multi;
    300263    Params.framer = ether_frameout;
     
    353316        Log(("vboxNetAdpDarwinUnregisterDevice: Failed to bring down interface "
    354317             "(err=%d).\n", err));
    355     /* Detach all protocols. */
    356     for (i = 0; i < VBOXNETADP_MAX_FAMILIES; i++)
    357         if (pThis->u.s.aAttachedFamilies[i])
    358             ifnet_detach_protocol(pThis->u.s.pIface, pThis->u.s.aAttachedFamilies[i]);
    359318    err = ifnet_detach(pThis->u.s.pIface);
    360319    if (err)
     
    470429    pThis->u.s.pIface = NULL;
    471430    pThis->u.s.hEvtDetached = NIL_RTSEMEVENT;
    472     memset(pThis->u.s.aAttachedFamilies, 0, sizeof(pThis->u.s.aAttachedFamilies));
    473431
    474432    return VINF_SUCCESS;
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