Lines Matching refs:pNetwork

270     struct INTNETNETWORK   *pNetwork;
308 struct INTNETNETWORK *pNetwork;
460 static void intnetR0TrunkIfDestroy(PINTNETTRUNKIF pThis, PINTNETNETWORK pNetwork);
469 * @param pNetwork The pointer that must be validated.
471 DECLINLINE(bool) intnetR0NetworkIsValid(PINTNET pIntNet, PINTNETNETWORK pNetwork)
474 if (pCurr == pNetwork)
669 * @param pNetwork The network.
672 static void intnetR0BusyWait(PINTNETNETWORK pNetwork, uint32_t volatile *pcBusy)
683 RTSemEventWait(pNetwork->hEvtBusyIf, 0); /* clear it */
696 int rc2 = RTSemEventWait(pNetwork->hEvtBusyIf, 30000); NOREF(rc2);
710 * @param pNetwork The network.
713 DECLINLINE(void) intnetR0BusyDec(PINTNETNETWORK pNetwork, uint32_t volatile *pcBusy)
717 && pNetwork))
718 RTSemEventSignal(pNetwork->hEvtBusyIf);
732 intnetR0BusyDec(pIf->pNetwork, &pIf->cBusy);
746 intnetR0BusyDec(pTrunk->pNetwork, &pTrunk->cBusy);
854 * @param pNetwork The network.
857 DECLINLINE(PINTNETMACTABENTRY) intnetR0NetworkFindMacAddrEntry(PINTNETNETWORK pNetwork, PINTNETIF pIf)
859 uint32_t iIf = pNetwork->MacTab.cEntries;
862 if (pNetwork->MacTab.paEntries[iIf].pIf == pIf)
863 return &pNetwork->MacTab.paEntries[iIf];
1164 * @param pNetwork The network.
1170 DECLINLINE(void) intnetR0NetworkAddrCacheDelete(PINTNETNETWORK pNetwork, PCRTNETADDRU pAddr, INTNETADDRTYPE const enmType,
1173 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1175 uint32_t iIf = pNetwork->MacTab.cEntries;
1178 PINTNETIF pIf = pNetwork->MacTab.paEntries[iIf].pIf;
1184 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1194 * @param pNetwork The network.
1200 DECLINLINE(void) intnetR0NetworkAddrCacheDeleteMinusIf(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, PCRTNETADDRU pAddr,
1203 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1205 uint32_t iIf = pNetwork->MacTab.cEntries;
1208 PINTNETIF pIf = pNetwork->MacTab.paEntries[iIf].pIf;
1217 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1227 * @param pNetwork The network.
1232 DECLINLINE(PINTNETIF) intnetR0NetworkAddrCacheLookupIf(PINTNETNETWORK pNetwork, PCRTNETADDRU pAddr, INTNETADDRTYPE const enmType, uint8_t const cbAddr)
1234 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1236 uint32_t iIf = pNetwork->MacTab.cEntries;
1239 PINTNETIF pIf = pNetwork->MacTab.paEntries[iIf].pIf;
1244 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1249 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1267 PINTNETNETWORK pNetwork = pIf->pNetwork;
1268 AssertReturnVoid(pNetwork);
1269 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1274 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1315 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1476 * @param pNetwork The network to switch on.
1484 static INTNETSWDECISION intnetR0NetworkSwitchLevel3(PINTNETNETWORK pNetwork, PCRTMAC pDstMacAddr,
1493 PINTNETMACTAB pTab = &pNetwork->MacTab;
1494 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1507 PINTNETIF pIf = pTab->paEntries[iIfMac].pIf; AssertPtr(pIf); Assert(pIf->pNetwork == pNetwork);
1527 && pNetwork->MacTab.cPromiscuousNoTrunkEntries)
1536 PINTNETIF pIf = pTab->paEntries[iIfMac].pIf; AssertPtr(pIf); Assert(pIf->pNetwork == pNetwork);
1572 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1584 * @param pNetwork The network to switch on.
1589 static INTNETSWDECISION intnetR0NetworkPreSwitchUnicast(PINTNETNETWORK pNetwork, uint32_t fSrc, PCRTMAC pSrcAddr,
1599 PINTNETMACTAB pTab = &pNetwork->MacTab;
1600 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1629 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1639 * @param pNetwork The network to switch on.
1646 static INTNETSWDECISION intnetR0NetworkSwitchUnicast(PINTNETNETWORK pNetwork, uint32_t fSrc, PINTNETIF pIfSender,
1655 PINTNETMACTAB pTab = &pNetwork->MacTab;
1656 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1678 PINTNETIF pIf = pTab->paEntries[iIfMac].pIf; AssertPtr(pIf); Assert(pIf->pNetwork == pNetwork);
1693 && pNetwork->MacTab.cPromiscuousNoTrunkEntries)
1704 PINTNETIF pIf = pTab->paEntries[iIfMac].pIf; AssertPtr(pIf); Assert(pIf->pNetwork == pNetwork);
1742 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1753 * @param pNetwork The network to switch on.
1759 static INTNETSWDECISION intnetR0NetworkSwitchBroadcast(PINTNETNETWORK pNetwork, uint32_t fSrc, PINTNETIF pIfSender,
1767 PINTNETMACTAB pTab = &pNetwork->MacTab;
1768 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1780 PINTNETIF pIf = pTab->paEntries[iIfMac].pIf; AssertPtr(pIf); Assert(pIf->pNetwork == pNetwork);
1804 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1817 * @param pNetwork The network to switch on.
1821 static INTNETSWDECISION intnetR0NetworkSwitchTrunkAndPromisc(PINTNETNETWORK pNetwork, uint32_t fSrc, PINTNETDSTTAB pDstTab)
1828 PINTNETMACTAB pTab = &pNetwork->MacTab;
1829 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1844 PINTNETIF pIf = pTab->paEntries[iIfMac].pIf; AssertPtr(pIf); Assert(pIf->pNetwork == pNetwork);
1865 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1876 * @param pNetwork The network to switch on.
1880 static INTNETSWDECISION intnetR0NetworkSwitchTrunk(PINTNETNETWORK pNetwork, uint32_t fSrc, PINTNETDSTTAB pDstTab)
1887 PINTNETMACTAB pTab= &pNetwork->MacTab;
1888 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
1907 RTSpinlockRelease(pNetwork->hAddrSpinlock);
1936 * @param pNetwork The network to operate on.
1938 static int intnetR0NetworkEnsureTabSpace(PINTNETNETWORK pNetwork)
1945 PINTNETMACTAB pTab = &pNetwork->MacTab;
1973 intnetR0BusyWait(pNetwork, &pIf->cBusy);
1981 && pNetwork->MacTab.pTrunk)
1984 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
2007 intnetR0BusyWait(pNetwork, &pTrunk->cBusy);
2020 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
2035 RTSpinlockRelease(pNetwork->hAddrSpinlock);
2061 * @param pNetwork The network this frame was seen on.
2069 static void intnetR0NetworkSnoopDhcp(PINTNETNETWORK pNetwork, PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, uint32_t cbUdpPkt)
2129 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
2131 uint32_t iIf = pNetwork->MacTab.cEntries;
2134 PINTNETIF pCur = pNetwork->MacTab.paEntries[iIf].pIf;
2148 RTSpinlockRelease(pNetwork->hAddrSpinlock);
2165 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
2167 uint32_t iIf = pNetwork->MacTab.cEntries;
2170 PINTNETIF pCur = pNetwork->MacTab.paEntries[iIf].pIf;
2181 RTSpinlockRelease(pNetwork->hAddrSpinlock);
2196 * @param pNetwork The network this frame was seen on.
2199 static void intnetR0TrunkIfSnoopDhcp(PINTNETNETWORK pNetwork, PCINTNETSG pSG)
2211 if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR), cbPacket, pNetwork->pbTmp))
2214 pIpHdr = (PCRTNETIPV4)pNetwork->pbTmp;
2230 intnetR0NetworkSnoopDhcp(pNetwork, pIpHdr, (PCRTNETUDP)((uintptr_t)pIpHdr + cbIpHdr), cbPacket - cbIpHdr);
2242 * @param pNetwork The network this frame was seen on.
2245 static void intnetR0TrunkIfSnoopArp(PINTNETNETWORK pNetwork, PCINTNETSG pSG)
2263 && !intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR), cbPacket, pNetwork->pbTmp))
2265 pArpIPv4 = (PCRTNETARPIPV4)pNetwork->pbTmp;
2295 intnetR0NetworkAddrCacheDelete(pNetwork, (PCRTNETADDRU)&pArpIPv4->ar_spa,
2310 * @param pNetwork The network.
2314 static void intnetR0TrunkIfSnoopAddr(PINTNETNETWORK pNetwork, PCINTNETSG pSG, uint16_t EtherType)
2381 intnetR0TrunkIfSnoopDhcp(pNetwork, pSG);
2386 intnetR0TrunkIfSnoopArp(pNetwork, pSG);
2491 intnetR0NetworkSnoopDhcp(pIf->pNetwork, pIpHdr, pUdpHdr, cbPacket - cbHdr);
2909 * @param pNetwork The network the frame is being sent to.
2915 static void intnetR0TrunkIfSend(PINTNETTRUNKIF pThis, PINTNETNETWORK pNetwork, PINTNETIF pIfSender,
2922 AssertPtr(pNetwork);
2936 if ( (pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE)
2945 intnetR0TrunkIfSend(pThis, pNetwork, pIfSender, INTNETTRUNKDIR_HOST, pSG);
3019 * @param pNetwork The network the frame is being sent to.
3026 static bool intnetR0NetworkSharedMacDetectAndFixBroadcast(PINTNETNETWORK pNetwork, PINTNETSG pSG, PRTNETETHERHDR pEthHdr)
3028 NOREF(pNetwork);
3116 * @param pNetwork The network the frame is being sent to.
3120 static void intnetR0NetworkSnoopNAFromWire(PINTNETNETWORK pNetwork, PINTNETSG pSG, PRTNETETHERHDR pEthHdr)
3138 + sizeof(RTNETNDP), pNetwork->pbTmp))
3141 pIPv6 = (PRTNETIPV6)pNetwork->pbTmp;
3160 intnetR0NetworkAddrCacheDelete(pNetwork, (PCRTNETADDRU) &pNd->target_address,
3167 * @param pNetwork The network the frame is being sent to.
3173 static void intnetR0NetworkEditArpFromWire(PINTNETNETWORK pNetwork, PINTNETSG pSG, PRTNETETHERHDR pEthHdr)
3186 if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR), sizeof(RTNETARPIPV4), pNetwork->pbTmp))
3189 pArpIPv4 = (PRTNETARPIPV4)pNetwork->pbTmp;
3215 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
3217 if (pNetwork->MacTab.pTrunk)
3218 MacAddrTrunk = pNetwork->MacTab.pTrunk->MacAddr;
3221 RTSpinlockRelease(pNetwork->hAddrSpinlock);
3225 PINTNETIF pIf = intnetR0NetworkAddrCacheLookupIf(pNetwork, (PCRTNETADDRU)&pArpIPv4->ar_tpa,
3251 * @param pNetwork The network the frame is being sent to.
3257 static void intnetR0NetworkEditDhcpFromIntNet(PINTNETNETWORK pNetwork, PINTNETSG pSG, PRTNETETHERHDR pEthHdr)
3277 if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR), cbPacket, pNetwork->pbTmp))
3280 pIpHdr = (PCRTNETIPV4)pNetwork->pbTmp;
3348 && (pNetwork->fFlags & INTNET_OPEN_FLAGS_WORKAROUND_1))
3377 * @param pNetwork The network.
3381 DECLINLINE(bool) intnetR0NetworkIsContextOk(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, PCINTNETDSTTAB pDstTab)
3383 NOREF(pNetwork);
3413 * @param pNetwork The network.
3417 DECLINLINE(bool) intnetR0NetworkIsContextOkForBroadcast(PINTNETNETWORK pNetwork, uint32_t fSrc)
3431 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
3432 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
3436 || ( (!pNetwork->MacTab.fHostActive || (pTrunk->fNoPreemptDsts & INTNETTRUNKDIR_HOST) )
3437 && (!pNetwork->MacTab.fWireActive || (pTrunk->fNoPreemptDsts & INTNETTRUNKDIR_WIRE) ) );
3439 RTSpinlockRelease(pNetwork->hAddrSpinlock);
3452 * @param pNetwork The network the frame is being sent to.
3461 static INTNETSWDECISION intnetR0NetworkSharedMacFixAndSwitchBroadcast(PINTNETNETWORK pNetwork,
3474 if (!intnetR0NetworkIsContextOkForBroadcast(pNetwork, fSrc))
3485 intnetR0NetworkSnoopNAFromWire(pNetwork, pSG, pEthHdr);
3495 intnetR0NetworkEditArpFromWire(pNetwork, pSG, pEthHdr);
3505 intnetR0NetworkEditDhcpFromIntNet(pNetwork, pSG, pEthHdr);
3518 intnetR0TrunkIfSnoopAddr(pNetwork, pSG, EtherType);
3521 intnetR0TrunkIfSnoopArp(pNetwork, pSG);
3528 return intnetR0NetworkSwitchBroadcast(pNetwork, fSrc, pIfSender, pDstTab);
3539 * @param pNetwork The network the frame is being sent to.
3544 static INTNETSWDECISION intnetR0NetworkSharedMacFixAndSwitchUnicast(PINTNETNETWORK pNetwork, PINTNETSG pSG,
3559 return intnetR0NetworkSwitchTrunk(pNetwork, INTNETTRUNKDIR_WIRE, pDstTab);
3570 return intnetR0NetworkSwitchTrunk(pNetwork, INTNETTRUNKDIR_WIRE, pDstTab);
3582 return intnetR0NetworkSwitchTrunk(pNetwork, INTNETTRUNKDIR_WIRE, pDstTab);
3596 return intnetR0NetworkSharedMacFixAndSwitchBroadcast(pNetwork, INTNETTRUNKDIR_WIRE, NULL, pSG, pEthHdr, pDstTab);
3604 return intnetR0NetworkSwitchTrunkAndPromisc(pNetwork, INTNETTRUNKDIR_WIRE, pDstTab);
3611 INTNETSWDECISION enmSwDecision = intnetR0NetworkSwitchLevel3(pNetwork, &pEthHdr->DstMac,
3622 intnetR0TrunkIfSnoopAddr(pNetwork, pSG, RT_BE2H_U16(pEthHdr->EtherType));
3633 * @param pNetwork The network.
3636 static void intnetR0NetworkReleaseDstTab(PINTNETNETWORK pNetwork, PINTNETDSTTAB pDstTab)
3643 intnetR0BusyDec(pNetwork, &pTrunk->cBusy);
3663 * @param pNetwork The network.
3669 static void intnetR0NetworkDeliver(PINTNETNETWORK pNetwork, PINTNETDSTTAB pDstTab, PINTNETSG pSG, PINTNETIF pIfSender)
3703 intnetR0TrunkIfSend(pTrunk, pNetwork, pIfSender, pDstTab->fTrunkDst, pSG);
3704 intnetR0BusyDec(pNetwork, &pTrunk->cBusy);
3721 * @param pNetwork The network the frame is being sent to.
3727 static INTNETSWDECISION intnetR0NetworkSend(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc,
3733 AssertPtr(pNetwork);
3736 Assert(!pIfSender || pNetwork == pIfSender->pNetwork);
3774 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
3776 PINTNETMACTABENTRY pIfEntry = intnetR0NetworkFindMacAddrEntry(pNetwork, pIfSender);
3781 RTSpinlockRelease(pNetwork->hAddrSpinlock);
3789 if (pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE)
3792 enmSwDecision = intnetR0NetworkSharedMacFixAndSwitchBroadcast(pNetwork, fSrc, pIfSender, pSG, &EthHdr, pDstTab);
3795 if (intnetR0NetworkSharedMacDetectAndFixBroadcast(pNetwork, pSG, &EthHdr))
3796 enmSwDecision = intnetR0NetworkSharedMacFixAndSwitchBroadcast(pNetwork, fSrc, pIfSender, pSG, &EthHdr, pDstTab);
3798 enmSwDecision = intnetR0NetworkSharedMacFixAndSwitchUnicast(pNetwork, pSG, &EthHdr, pDstTab);
3801 enmSwDecision = intnetR0NetworkSwitchUnicast(pNetwork, fSrc, pIfSender, &EthHdr.DstMac, pDstTab);
3804 enmSwDecision = intnetR0NetworkSwitchBroadcast(pNetwork, fSrc, pIfSender, pDstTab);
3806 enmSwDecision = intnetR0NetworkSwitchUnicast(pNetwork, fSrc, pIfSender, &EthHdr.DstMac, pDstTab);
3813 if (intnetR0NetworkIsContextOk(pNetwork, pIfSender, pDstTab))
3814 intnetR0NetworkDeliver(pNetwork, pDstTab, pSG, pIfSender);
3817 intnetR0NetworkReleaseDstTab(pNetwork, pDstTab);
3862 PINTNETNETWORK pNetwork = pIf->pNetwork;
3863 if (RT_LIKELY(pNetwork))
3887 if (pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE)
3889 enmSwDecision = intnetR0NetworkSend(pNetwork, pIf, 0 /*fSrc*/, &Sg, pDstTab);
3900 if (pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE)
3902 enmSwDecision = intnetR0NetworkSend(pNetwork, pIf, 0 /*fSrc*/, &Sg, pDstTab);
4064 int rc = RTSemFastMutexRequest(pIf->pNetwork->FastMutex);
4070 rc = RTSemFastMutexRelease(pIf->pNetwork->FastMutex);
4110 PINTNETNETWORK pNetwork = pIf->pNetwork;
4111 if (pNetwork)
4113 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
4119 && (pNetwork->fFlags & INTNET_OPEN_FLAGS_PROMISC_ALLOW_CLIENTS);
4125 PINTNETMACTABENTRY pEntry = intnetR0NetworkFindMacAddrEntry(pNetwork, pIf); Assert(pEntry);
4130 pNetwork->MacTab.cPromiscuousEntries--;
4132 pNetwork->MacTab.cPromiscuousNoTrunkEntries--;
4133 Assert(pNetwork->MacTab.cPromiscuousEntries < pNetwork->MacTab.cEntries);
4134 Assert(pNetwork->MacTab.cPromiscuousNoTrunkEntries < pNetwork->MacTab.cEntries);
4143 pNetwork->MacTab.cPromiscuousEntries++;
4145 pNetwork->MacTab.cPromiscuousNoTrunkEntries++;
4147 Assert(pNetwork->MacTab.cPromiscuousEntries <= pNetwork->MacTab.cEntries);
4148 Assert(pNetwork->MacTab.cPromiscuousNoTrunkEntries <= pNetwork->MacTab.cEntries);
4152 RTSpinlockRelease(pNetwork->hAddrSpinlock);
4211 PINTNETNETWORK pNetwork = pIf->pNetwork;
4212 if (pNetwork)
4216 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
4224 PINTNETMACTABENTRY pEntry = intnetR0NetworkFindMacAddrEntry(pNetwork, pIf); Assert(pEntry);
4231 pTrunk = pNetwork->MacTab.pTrunk;
4236 RTSpinlockRelease(pNetwork->hAddrSpinlock);
4280 * @param pNetwork The network.
4284 static int intnetR0NetworkSetIfActive(PINTNETNETWORK pNetwork, PINTNETIF pIf, bool fActive)
4287 AssertPtr(pNetwork);
4296 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
4303 PINTNETMACTABENTRY pEntry = intnetR0NetworkFindMacAddrEntry(pNetwork, pIf); Assert(pEntry);
4311 pNetwork->cActiveIFs++;
4312 if (pNetwork->cActiveIFs == 1)
4314 pTrunk = pNetwork->MacTab.pTrunk;
4317 pNetwork->MacTab.fHostActive = RT_BOOL(pNetwork->fFlags & INTNET_OPEN_FLAGS_TRUNK_HOST_ENABLED);
4318 pNetwork->MacTab.fWireActive = RT_BOOL(pNetwork->fFlags & INTNET_OPEN_FLAGS_TRUNK_WIRE_ENABLED);
4324 pNetwork->cActiveIFs--;
4325 if (pNetwork->cActiveIFs == 0)
4327 pTrunk = pNetwork->MacTab.pTrunk;
4328 pNetwork->MacTab.fHostActive = false;
4329 pNetwork->MacTab.fWireActive = false;
4335 RTSpinlockRelease(pNetwork->hAddrSpinlock);
4344 intnetR0BusyWait(pNetwork, &pTrunk->cBusy);
4397 PINTNETNETWORK pNetwork = pIf->pNetwork;
4398 if (pNetwork)
4399 rc = intnetR0NetworkSetIfActive(pNetwork, pIf, fActive);
4693 PINTNETNETWORK pNetwork = pIf->pNetwork;
4694 if (pNetwork)
4697 intnetR0NetworkSetIfActive(pNetwork, pIf, false /*fActive*/);
4700 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
4702 uint32_t iIf = pNetwork->MacTab.cEntries;
4704 if (pNetwork->MacTab.paEntries[iIf].pIf == pIf)
4706 if (pNetwork->MacTab.paEntries[iIf].fPromiscuousEff)
4708 pNetwork->MacTab.cPromiscuousEntries--;
4709 if (!pNetwork->MacTab.paEntries[iIf].fPromiscuousSeeTrunk)
4710 pNetwork->MacTab.cPromiscuousNoTrunkEntries--;
4712 Assert(pNetwork->MacTab.cPromiscuousEntries < pNetwork->MacTab.cEntries);
4713 Assert(pNetwork->MacTab.cPromiscuousNoTrunkEntries < pNetwork->MacTab.cEntries);
4715 if (iIf + 1 < pNetwork->MacTab.cEntries)
4716 memmove(&pNetwork->MacTab.paEntries[iIf],
4717 &pNetwork->MacTab.paEntries[iIf + 1],
4718 (pNetwork->MacTab.cEntries - iIf - 1) * sizeof(pNetwork->MacTab.paEntries[0]));
4719 pNetwork->MacTab.cEntries--;
4727 iIf = pNetwork->MacTab.cEntries;
4730 PINTNETIF pIf2 = pNetwork->MacTab.paEntries[iIf].pIf;
4735 pNetwork->fMinFlags = fMinFlags;
4738 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
4740 RTSpinlockRelease(pNetwork->hAddrSpinlock);
4747 intnetR0BusyWait(pNetwork, &pIf->cBusy);
4750 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
4751 pIf->pNetwork = NULL;
4752 RTSpinlockRelease(pNetwork->hAddrSpinlock);
4754 SUPR0ObjRelease(pNetwork->pvObj, pIf->pSession);
4835 * @param pNetwork The network, referenced. The reference is consumed on
4843 static int intnetR0NetworkCreateIf(PINTNETNETWORK pNetwork, PSUPDRVSESSION pSession,
4847 LogFlow(("intnetR0NetworkCreateIf: pNetwork=%p pSession=%p cbSend=%u cbRecv=%u fFlags=%#x phIf=%p\n",
4848 pNetwork, pSession, cbSend, cbRecv, fFlags, phIf));
4853 AssertPtr(pNetwork);
4869 int rc = intnetR0NetworkEnsureTabSpace(pNetwork);
4894 pIf->pNetwork = pNetwork;
4905 !!(pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE));
4907 rc = intnetR0AllocDstTab(pNetwork->MacTab.cEntriesAllocated, (PINTNETDSTTAB *)&pIf->pDstTab);
4934 intnetR0IfDestruct, pIf, pNetwork->pIntNet);
4937 rc = RTHandleTableAllocWithCtx(pNetwork->pIntNet->hHtIfs, pIf, pSession, (uint32_t *)&pIf->hIf);
4944 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
4946 uint32_t iIf = pNetwork->MacTab.cEntries;
4947 Assert(iIf + 1 <= pNetwork->MacTab.cEntriesAllocated);
4949 pNetwork->MacTab.paEntries[iIf].MacAddr = pIf->MacAddr;
4950 pNetwork->MacTab.paEntries[iIf].fActive = false;
4951 pNetwork->MacTab.paEntries[iIf].fPromiscuousEff = false;
4952 pNetwork->MacTab.paEntries[iIf].fPromiscuousSeeTrunk = false;
4953 pNetwork->MacTab.paEntries[iIf].pIf = pIf;
4955 pNetwork->MacTab.cEntries = iIf + 1;
4956 pIf->pNetwork = pNetwork;
4962 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
4966 RTSpinlockRelease(pNetwork->hAddrSpinlock);
4987 SUPR0ObjAddRef(pNetwork->pvObj, pSession);
5032 PINTNETNETWORK pNetwork = pThis->pNetwork;
5033 if (pNetwork)
5035 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
5037 pNetwork->MacTab.HostMac = *pMacAddr;
5040 RTSpinlockRelease(pNetwork->hAddrSpinlock);
5058 PINTNETNETWORK pNetwork = pThis->pNetwork;
5059 if (pNetwork)
5061 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
5063 pNetwork->MacTab.fHostPromiscuousReal = fPromiscuous
5064 || (pNetwork->fFlags & INTNET_OPEN_FLAGS_TRUNK_HOST_PROMISC_MODE);
5065 pNetwork->MacTab.fHostPromiscuousEff = pNetwork->MacTab.fHostPromiscuousReal
5066 && (pNetwork->fFlags & INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_HOST);
5068 RTSpinlockRelease(pNetwork->hAddrSpinlock);
5114 * the interface to stop being busy before setting pNetwork to NULL and
5117 PINTNETNETWORK pNetwork = pThis->pNetwork;
5118 if (pNetwork)
5120 PINTNET pIntNet = pNetwork->pIntNet;
5121 Assert(pNetwork->pIntNet);
5134 if (intnetR0NetworkIsValid(pIntNet, pNetwork))
5136 Assert(pNetwork->MacTab.pTrunk == pThis); /* Must be valid as long as tehre are no concurrent calls to this method. */
5145 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
5146 pNetwork->MacTab.pTrunk = NULL;
5147 RTSpinlockRelease(pNetwork->hAddrSpinlock);
5149 intnetR0TrunkIfDestroy(pThis, pNetwork);
5179 PINTNETNETWORK pNetwork = pThis->pNetwork;
5180 if (RT_LIKELY( pNetwork
5181 && pNetwork->cActiveIFs > 0 ))
5190 && (pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE))
5193 enmSwDecision = intnetR0NetworkPreSwitchUnicast(pNetwork,
5220 PINTNETNETWORK pNetwork = pThis->pNetwork;
5221 if (RT_LIKELY( pNetwork
5222 && pNetwork->cActiveIFs > 0 ))
5271 intnetR0AllocDstTab(pNetwork->MacTab.cEntriesAllocated, &pDstTab);
5280 INTNETSWDECISION enmSwDecision = intnetR0NetworkSend(pNetwork, NULL, fSrc, pSG, pDstTab);
5324 PINTNETNETWORK pNetwork = pThis->pNetwork;
5327 AssertPtrReturnVoid(pNetwork);
5328 AssertReturnVoid(pNetwork->hEvtBusyIf != NIL_RTSEMEVENT);
5341 PINTNETNETWORK pNetwork = pThis->pNetwork;
5344 AssertPtrReturnVoid(pNetwork);
5345 AssertReturnVoid(pNetwork->hEvtBusyIf != NIL_RTSEMEVENT);
5367 static void intnetR0TrunkIfDestroy(PINTNETTRUNKIF pThis, PINTNETNETWORK pNetwork)
5373 Assert(pThis->pNetwork == pNetwork);
5392 pNetwork->szName, RTTimeSystemNanoTS() - StartTS, rc));
5400 pNetwork->szName, RTTimeSystemNanoTS() - StartTS, rc));
5407 pNetwork->szName, RTTimeSystemNanoTS() - StartTS, rc));
5420 pThis->pNetwork = NULL; /* Must not be cleared while busy, see intnetR0TrunkIfPortDisconnect. */
5443 * @param pNetwork The newly created network.
5446 static int intnetR0NetworkCreateTrunkIf(PINTNETNETWORK pNetwork, PSUPDRVSESSION pSession)
5449 switch (pNetwork->enmTrunkType)
5502 Assert(pNetwork->MacTab.cEntriesAllocated > 0);
5506 rc = intnetR0AllocDstTab(pNetwork->MacTab.cEntriesAllocated, &pTrunk->apIntDstTabs[i]);
5508 rc = intnetR0AllocDstTab(pNetwork->MacTab.cEntriesAllocated, &pTrunk->apTaskDstTabs[i]);
5525 pTrunk->pNetwork = pNetwork;
5556 pNetwork->MacTab.pTrunk = pTrunk;
5557 pNetwork->MacTab.HostMac = pTrunk->MacAddr;
5558 pNetwork->MacTab.fHostPromiscuousReal = false;
5559 pNetwork->MacTab.fHostPromiscuousEff = (pNetwork->fFlags & INTNET_OPEN_FLAGS_TRUNK_HOST_PROMISC_MODE)
5560 && (pNetwork->fFlags & INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_HOST);
5561 pNetwork->MacTab.fHostActive = false;
5562 pNetwork->MacTab.fWirePromiscuousReal = RT_BOOL(pNetwork->fFlags & INTNET_OPEN_FLAGS_TRUNK_WIRE_PROMISC_MODE);
5563 pNetwork->MacTab.fWirePromiscuousEff = pNetwork->MacTab.fWirePromiscuousReal
5564 && (pNetwork->fFlags & INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_WIRE);
5565 pNetwork->MacTab.fWireActive = false;
5576 pNetwork->szTrunk,
5578 pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE
5588 pszName, pNetwork->szTrunk, pNetwork->fFlags & INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE ? " shared-mac" : "", pNetwork->szName));
5597 pNetwork->MacTab.pTrunk = NULL;
5611 rc, pszName, pNetwork->szTrunk, pNetwork->szName));
5627 PINTNETNETWORK pNetwork = (PINTNETNETWORK)pvUser1;
5629 Log(("intnetR0NetworkDestruct: pvObj=%p pNetwork=%p pIntNet=%p %s\n", pvObj, pNetwork, pIntNet, pNetwork->szName));
5630 Assert(pNetwork->pIntNet == pIntNet);
5639 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
5651 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
5653 uint32_t iIf = pNetwork->MacTab.cEntries;
5656 pNetwork->MacTab.paEntries[iIf].fActive = false;
5657 pNetwork->MacTab.paEntries[iIf].pIf->fActive = false;
5660 pNetwork->MacTab.fHostActive = false;
5661 pNetwork->MacTab.fWireActive = false;
5663 RTSpinlockRelease(pNetwork->hAddrSpinlock);
5668 intnetR0BusyWait(pNetwork, &pTrunk->cBusy);
5670 iIf = pNetwork->MacTab.cEntries;
5672 intnetR0BusyWait(pNetwork, &pNetwork->MacTab.paEntries[iIf].pIf->cBusy);
5676 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
5677 while ((iIf = pNetwork->MacTab.cEntries) > 0)
5679 PINTNETIF pIf = pNetwork->MacTab.paEntries[iIf - 1].pIf;
5680 RTSpinlockRelease(pNetwork->hAddrSpinlock);
5682 intnetR0BusyWait(pNetwork, &pIf->cBusy);
5684 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
5685 if ( iIf == pNetwork->MacTab.cEntries /* paranoia */
5688 pIf->pNetwork = NULL;
5689 pNetwork->MacTab.cEntries--;
5697 pNetwork->MacTab.pTrunk = NULL;
5699 RTSpinlockRelease(pNetwork->hAddrSpinlock);
5702 intnetR0TrunkIfDestroy(pTrunk, pNetwork);
5709 if (pPrev == pNetwork)
5710 pIntNet->pNetworks = pNetwork->pNext;
5714 if (pPrev->pNext == pNetwork)
5716 pPrev->pNext = pNetwork->pNext;
5720 pNetwork->pNext = NULL;
5721 pNetwork->pvObj = NULL;
5726 RTSemEventDestroy(pNetwork->hEvtBusyIf);
5727 pNetwork->hEvtBusyIf = NIL_RTSEMEVENT;
5728 RTSpinlockDestroy(pNetwork->hAddrSpinlock);
5729 pNetwork->hAddrSpinlock = NIL_RTSPINLOCK;
5730 RTMemFree(pNetwork->MacTab.paEntries);
5731 pNetwork->MacTab.paEntries = NULL;
5732 RTMemFree(pNetwork);
5743 * @param pNetwork The network.
5746 static int intnetR0CheckOpenNetworkFlags(PINTNETNETWORK pNetwork, uint32_t fFlags)
5748 uint32_t const fNetFlags = pNetwork->fFlags;
5780 * @param pNetwork The network.
5783 static int intnetR0AdaptOpenNetworkFlags(PINTNETNETWORK pNetwork, uint32_t fFlags)
5788 uint32_t fNetMinFlags = pNetwork->fMinFlags;
5793 if (fNetMinFlags != pNetwork->fMinFlags)
5795 LogRel(("INTNET: %s - min flags changed %#x -> %#x\n", pNetwork->szName, pNetwork->fMinFlags, fNetMinFlags));
5796 pNetwork->fMinFlags = fNetMinFlags;
5804 uint32_t fNetFlags = pNetwork->fFlags;
5838 uint32_t const fOldNetFlags = pNetwork->fFlags;
5841 LogRel(("INTNET: %s - flags changed %#x -> %#x\n", pNetwork->szName, fOldNetFlags, fNetFlags));
5843 RTSpinlockAcquire(pNetwork->hAddrSpinlock);
5845 pNetwork->fFlags = fNetFlags;
5848 bool fActiveTrunk = pNetwork->MacTab.pTrunk
5849 && pNetwork->cActiveIFs > 0;
5850 pNetwork->MacTab.fHostActive = fActiveTrunk
5852 pNetwork->MacTab.fHostPromiscuousEff = ( pNetwork->MacTab.fHostPromiscuousReal
5856 pNetwork->MacTab.fWireActive = fActiveTrunk
5858 pNetwork->MacTab.fWirePromiscuousReal= RT_BOOL(fNetFlags & INTNET_OPEN_FLAGS_TRUNK_WIRE_PROMISC_MODE);
5859 pNetwork->MacTab.fWirePromiscuousEff = pNetwork->MacTab.fWirePromiscuousReal
5864 pNetwork->MacTab.cPromiscuousEntries = 0;
5865 pNetwork->MacTab.cPromiscuousNoTrunkEntries = 0;
5867 uint32_t iIf = pNetwork->MacTab.cEntries;
5870 PINTNETMACTABENTRY pEntry = &pNetwork->MacTab.paEntries[iIf];
5883 pNetwork->MacTab.cPromiscuousEntries++;
5885 pNetwork->MacTab.cPromiscuousNoTrunkEntries++;
5891 RTSpinlockRelease(pNetwork->hAddrSpinlock);
6064 PINTNETNETWORK pNetwork = (PINTNETNETWORK)RTMemAllocZ(cb);
6065 if (!pNetwork)
6067 //pNetwork->pNext = NULL;
6068 //pNetwork->pIfs = NULL;
6069 pNetwork->hAddrSpinlock = NIL_RTSPINLOCK;
6070 pNetwork->MacTab.cEntries = 0;
6071 pNetwork->MacTab.cEntriesAllocated = INTNET_GROW_DSTTAB_SIZE;
6072 //pNetwork->MacTab.cPromiscuousEntries = 0;
6073 //pNetwork->MacTab.cPromiscuousNoTrunkEntries = 0;
6074 pNetwork->MacTab.paEntries = NULL;
6075 pNetwork->MacTab.fHostPromiscuousReal = false;
6076 pNetwork->MacTab.fHostPromiscuousEff = false;
6077 pNetwork->MacTab.fHostActive = false;
6078 pNetwork->MacTab.fWirePromiscuousReal = false;
6079 pNetwork->MacTab.fWirePromiscuousEff = false;
6080 pNetwork->MacTab.fWireActive = false;
6081 pNetwork->MacTab.pTrunk = NULL;
6082 pNetwork->hEvtBusyIf = NIL_RTSEMEVENT;
6083 pNetwork->pIntNet = pIntNet;
6084 //pNetwork->pvObj = NULL;
6086 pNetwork->pbTmp = RT_ALIGN_PT(pNetwork + 1, 64, uint8_t *);
6088 // pNetwork->pbTmp = NULL;
6089 pNetwork->fFlags = fFlags;
6090 //pNetwork->fMinFlags = 0;
6091 //pNetwork->cActiveIFs = 0;
6093 pNetwork->cchName = (uint8_t)cchName;
6094 Assert(cchName && cchName < sizeof(pNetwork->szName)); /* caller's responsibility. */
6095 memcpy(pNetwork->szName, pszNetwork, cchName); /* '\0' at courtesy of alloc. */
6096 pNetwork->enmTrunkType = enmTrunkType;
6097 Assert(strlen(pszTrunk) < sizeof(pNetwork->szTrunk)); /* caller's responsibility. */
6098 strcpy(pNetwork->szTrunk, pszTrunk);
6103 int rc = RTSemEventCreate(&pNetwork->hEvtBusyIf);
6105 rc = RTSpinlockCreate(&pNetwork->hAddrSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "hAddrSpinlock");
6108 pNetwork->MacTab.paEntries = (PINTNETMACTABENTRY)RTMemAlloc(sizeof(INTNETMACTABENTRY) * pNetwork->MacTab.cEntriesAllocated);
6109 if (!pNetwork->MacTab.paEntries)
6117 pNetwork->pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_INTERNAL_NETWORK, intnetR0NetworkDestruct, pNetwork, pIntNet);
6118 if (pNetwork->pvObj)
6120 pNetwork->pNext = pIntNet->pNetworks;
6121 pIntNet->pNetworks = pNetwork;
6129 rc = SUPR0ObjVerifyAccess(pNetwork->pvObj, pSession, pNetwork->szName);
6135 rc = intnetR0NetworkCreateTrunkIf(pNetwork, pSession);
6138 *ppNetwork = pNetwork;
6139 LogFlow(("intnetR0CreateNetwork: returns VINF_SUCCESS *ppNetwork=%p\n", pNetwork));
6144 SUPR0ObjRelease(pNetwork->pvObj, pSession);
6153 RTSemEventDestroy(pNetwork->hEvtBusyIf);
6154 pNetwork->hEvtBusyIf = NIL_RTSEMEVENT;
6155 RTSpinlockDestroy(pNetwork->hAddrSpinlock);
6156 pNetwork->hAddrSpinlock = NIL_RTSPINLOCK;
6157 RTMemFree(pNetwork->MacTab.paEntries);
6158 pNetwork->MacTab.paEntries = NULL;
6159 RTMemFree(pNetwork);
6252 PINTNETNETWORK pNetwork = NULL;
6253 rc = intnetR0OpenNetwork(pIntNet, pSession, pszNetwork, enmTrunkType, pszTrunk, fFlags, &pNetwork);
6256 rc = intnetR0NetworkCreateIf(pNetwork, pSession, cbSend, cbRecv, fFlags, phIf);
6259 intnetR0AdaptOpenNetworkFlags(pNetwork, fFlags);
6263 SUPR0ObjRelease(pNetwork->pvObj, pSession);
6267 rc = intnetR0CreateNetwork(pIntNet, pSession, pszNetwork, enmTrunkType, pszTrunk, fFlags, &pNetwork);
6270 rc = intnetR0NetworkCreateIf(pNetwork, pSession, cbSend, cbRecv, fFlags, phIf);
6272 SUPR0ObjRelease(pNetwork->pvObj, pSession);