Changeset 28666 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin
- Timestamp:
- Apr 23, 2010 5:25:58 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60537
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp
r28077 r28666 615 615 AssertMsg(!pvFrame, ("pvFrame=%p pMBuf=%p iSeg=%d\n", pvFrame, pMBuf, iSeg)); 616 616 } 617 618 619 /** 620 * Helper for determining whether the host wants the interface to be 621 * promiscuous. 622 */ 623 static bool vboxNetFltDarwinIsPromiscuous(PVBOXNETFLTINS pThis) 624 { 625 bool fRc = false; 626 ifnet_t pIfNet = vboxNetFltDarwinRetainIfNet(pThis); 627 if (pIfNet) 628 { 629 /* gather the data */ 630 uint16_t fIf = ifnet_flags(pIfNet); 631 unsigned cPromisc = VBOX_GET_PCOUNT(pIfNet); 632 bool fSetPromiscuous = ASMAtomicUoReadBool(&pThis->u.s.fSetPromiscuous); 633 vboxNetFltDarwinReleaseIfNet(pThis, pIfNet); 634 635 /* calc the return. */ 636 fRc = (fIf & IFF_PROMISC) 637 && cPromisc > fSetPromiscuous; 638 } 639 return fRc; 640 } 641 617 642 618 643 … … 751 776 else if (pEvMsg->event_code == KEV_DL_LINK_OFF) 752 777 Log(("vboxNetFltDarwinIffEvent: %s goes down (%d)\n", pThis->szName, VBOX_GET_PCOUNT(pIfNet))); 778 /** @todo KEV_DL_LINK_ADDRESS_CHANGED -> pfnReportMacAddress */ 779 /** @todo KEV_DL_SIFFLAGS -> pfnReportPromiscuousMode */ 753 780 } 754 781 else … … 903 930 * Get the mac address while we still have a valid ifnet reference. 904 931 */ 905 err = ifnet_lladdr_copy_bytes(pIfNet, &pThis->u.s.Mac , sizeof(pThis->u.s.Mac));932 err = ifnet_lladdr_copy_bytes(pIfNet, &pThis->u.s.MacAddr, sizeof(pThis->u.s.MacAddr)); 906 933 if (!err) 907 934 { … … 931 958 } 932 959 RTSpinlockRelease(pThis->hSpinlock, &Tmp); 960 961 /* Report capabilities. */ 962 if (!pIfNet) 963 { 964 Assert(pThis->pSwitchPort); 965 pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr); 966 pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltDarwinIsPromiscuous(pThis)); 967 pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST); 968 } 933 969 } 934 970 … … 939 975 int rc = RTErrConvertFromErrno(err); 940 976 if (RT_SUCCESS(rc)) 941 LogRel(("VBoxFltDrv: attached to '%s' / %.*Rhxs\n", pThis->szName, sizeof(pThis->u.s.Mac ), &pThis->u.s.Mac));977 LogRel(("VBoxFltDrv: attached to '%s' / %.*Rhxs\n", pThis->szName, sizeof(pThis->u.s.MacAddr), &pThis->u.s.MacAddr)); 942 978 else 943 979 LogRel(("VBoxFltDrv: failed to attach to ifnet '%s' (err=%d)\n", pThis->szName, err)); … … 1002 1038 1003 1039 return rc; 1004 }1005 1006 1007 bool vboxNetFltPortOsIsPromiscuous(PVBOXNETFLTINS pThis)1008 {1009 bool fRc = false;1010 ifnet_t pIfNet = vboxNetFltDarwinRetainIfNet(pThis);1011 if (pIfNet)1012 {1013 /* gather the data */1014 uint16_t fIf = ifnet_flags(pIfNet);1015 unsigned cPromisc = VBOX_GET_PCOUNT(pIfNet);1016 bool fSetPromiscuous = ASMAtomicUoReadBool(&pThis->u.s.fSetPromiscuous);1017 vboxNetFltDarwinReleaseIfNet(pThis, pIfNet);1018 1019 /* calc the return. */1020 fRc = (fIf & IFF_PROMISC)1021 && cPromisc > fSetPromiscuous;1022 }1023 return fRc;1024 }1025 1026 1027 void vboxNetFltPortOsGetMacAddress(PVBOXNETFLTINS pThis, PRTMAC pMac)1028 {1029 *pMac = pThis->u.s.Mac;1030 }1031 1032 1033 bool vboxNetFltPortOsIsHostMac(PVBOXNETFLTINS pThis, PCRTMAC pMac)1034 {1035 /* ASSUMES that the MAC address never changes. */1036 return pThis->u.s.Mac.au16[0] == pMac->au16[0]1037 && pThis->u.s.Mac.au16[1] == pMac->au16[1]1038 && pThis->u.s.Mac.au16[2] == pMac->au16[2];1039 1040 } 1040 1041 … … 1192 1193 pThis->u.s.fSetPromiscuous = false; 1193 1194 pThis->u.s.fNeedSetPromiscuous = false; 1194 //pThis->u.s.Mac = {0};1195 //pThis->u.s.MacAddr = {0}; 1195 1196 1196 1197 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.