Skip to content

Commit

Permalink
network,wifi: lambda [=] doesn't implicitly capture this in c++20
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabrielcarvfer committed Oct 19, 2023
1 parent 2622354 commit bb491ed
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/network/utils/net-device-queue-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ NetDeviceQueue::PacketDequeued(QueueType* queue, Ptr<const typename QueueType::I
NS_LOG_FUNCTION(this << queue << item);
NS_ASSERT_MSG(m_device, "Aggregated NetDevice not set");

Simulator::ScheduleNow([=]() {
Simulator::ScheduleNow([=, this]() {
// Inform BQL
NotifyTransmittedBytes(item->GetSize());

Expand Down
4 changes: 2 additions & 2 deletions src/wifi/model/ap-wifi-mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ ApWifiMac::ReceiveEmlOmn(MgtEmlOmn& frame, const Mac48Address& sender, uint8_t l
// completed. For this purpose, we connect a callback to the PHY TX begin trace to catch
// the Ack transmitted after the EML Notification frame.
CallbackBase cb = Callback<void, WifiConstPsduMap, WifiTxVector, double>(
[=](WifiConstPsduMap psduMap, WifiTxVector txVector, double /* txPowerW */) {
[=, this](WifiConstPsduMap psduMap, WifiTxVector txVector, double /* txPowerW */) {
NS_ASSERT_MSG(psduMap.size() == 1 && psduMap.begin()->second->GetNMpdus() == 1 &&
psduMap.begin()->second->GetHeader(0).IsAck(),
"Expected a Normal Ack after EML Notification frame");
Expand All @@ -2223,7 +2223,7 @@ ApWifiMac::ReceiveEmlOmn(MgtEmlOmn& frame, const Mac48Address& sender, uint8_t l
ehtConfiguration->GetAttribute("TransitionTimeout", transitionTimeout);

m_transitionTimeoutEvents[sender] =
Simulator::Schedule(ackDuration + transitionTimeout.Get(), [=]() {
Simulator::Schedule(ackDuration + transitionTimeout.Get(), [=, this]() {
for (uint8_t id = 0; id < GetNLinks(); id++)
{
auto linkAddress =
Expand Down
6 changes: 3 additions & 3 deletions src/wifi/model/eht/eht-frame-exchange-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ EhtFrameExchangeManager::StartTransmission(Ptr<Txop> edca, uint16_t allowedWidth
edca->NotifyChannelReleased(m_linkId);
NS_LOG_DEBUG("No new TXOP attempts allowed while MediumSyncDelay is running");
// request channel access if needed when the MediumSyncDelay timer expires
Simulator::Schedule(emlsrManager->GetMediumSyncDuration() - *elapsed, [=]() {
Simulator::Schedule(emlsrManager->GetMediumSyncDuration() - *elapsed, [=, this]() {
if (edca->GetAccessStatus(m_linkId) == Txop::NOT_REQUESTED &&
edca->HasFramesToTransmit(m_linkId))
{
Expand Down Expand Up @@ -278,7 +278,7 @@ EhtFrameExchangeManager::EmlsrSwitchToListening(const Mac48Address& address, con
{
if (m_mac->GetWifiRemoteStationManager(linkId)->GetEmlsrEnabled(*mldAddress))
{
Simulator::Schedule(delay, [=]() {
Simulator::Schedule(delay, [=, this]() {
if (linkId != m_linkId)
{
// the reason for blocking the other EMLSR links has changed now
Expand All @@ -296,7 +296,7 @@ EhtFrameExchangeManager::EmlsrSwitchToListening(const Mac48Address& address, con
// unblock all EMLSR links when the transition delay elapses
Simulator::Schedule(delay + CommonInfoBasicMle::DecodeEmlsrTransitionDelay(
emlCapabilities->get().emlsrTransitionDelay),
[=]() {
[=, this]() {
m_mac->UnblockUnicastTxOnLinks(
WifiQueueBlockedReason::WAITING_EMLSR_TRANSITION_DELAY,
*mldAddress,
Expand Down
4 changes: 2 additions & 2 deletions src/wifi/model/eht/emlsr-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ EmlsrManager::SwitchMainPhy(uint8_t linkId, bool noSwitchDelay)
"We should not ask the main PHY to switch channel while transmitting");

// request the main PHY to switch channel
Simulator::ScheduleNow([=]() {
Simulator::ScheduleNow([=, this]() {
auto delay = mainPhy->GetChannelSwitchDelay();
NS_ASSERT_MSG(noSwitchDelay || delay <= m_lastAdvTransitionDelay,
"Transition delay (" << m_lastAdvTransitionDelay.As(Time::US)
Expand Down Expand Up @@ -528,7 +528,7 @@ EmlsrManager::SwitchAuxPhy(uint8_t currLinkId, uint8_t nextLinkId)
->GetChannelAccessManager(currLinkId)
->NotifySwitchingEmlsrLink(auxPhy, newAuxPhyChannel, nextLinkId);

Simulator::ScheduleNow([=]() {
Simulator::ScheduleNow([=, this]() {
auxPhy->SetOperatingChannel(newAuxPhyChannel);
// re-enable short time slot, if needed
if (m_staMac->GetWifiRemoteStationManager(nextLinkId)->GetShortSlotTimeEnabled())
Expand Down
2 changes: 1 addition & 1 deletion src/wifi/model/sta-wifi-mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ StaWifiMac::SetPmModeAfterAssociation(uint8_t linkId)
// acknowledgement of the Association Response. For this purpose, we connect a callback to
// the PHY TX begin trace to catch the Ack transmitted after the Association Response.
CallbackBase cb = Callback<void, WifiConstPsduMap, WifiTxVector, double>(
[=](WifiConstPsduMap psduMap, WifiTxVector txVector, double /* txPowerW */) {
[=, this](WifiConstPsduMap psduMap, WifiTxVector txVector, double /* txPowerW */) {
NS_ASSERT_MSG(psduMap.size() == 1 && psduMap.begin()->second->GetNMpdus() == 1 &&
psduMap.begin()->second->GetHeader(0).IsAck(),
"Expected a Normal Ack after Association Response frame");
Expand Down
2 changes: 1 addition & 1 deletion src/wifi/model/wifi-mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ WifiMac::UnblockUnicastTxOnLinks(WifiQueueBlockedReason reason,
// request channel access if needed (schedule now because multiple invocations
// of this method may be done in a loop at the caller)
auto qosTxop = GetQosTxop(acIndex);
Simulator::ScheduleNow([=]() {
Simulator::ScheduleNow([=, this]() {
if (qosTxop->GetAccessStatus(linkId) == Txop::NOT_REQUESTED &&
qosTxop->HasFramesToTransmit(linkId))
{
Expand Down
14 changes: 7 additions & 7 deletions src/wifi/test/channel-access-manager-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ LargestIdlePrimaryChannelTest::RunOne(uint16_t chWidth, WifiChannelListType busy
: ((1 << (busyChannel - 1)) * 20);

Time checkTime1 = start + ccaBusyStartDelay + ccaBusyDuration / 2;
Simulator::Schedule(checkTime1 - start, [=]() {
Simulator::Schedule(checkTime1 - start, [=, this]() {
Time interval1 = (ccaBusyStartDelay + ccaBusyDuration) / 2;
NS_TEST_EXPECT_MSG_EQ(m_cam->GetLargestIdlePrimaryChannel(interval1, checkTime1),
idleWidth,
Expand All @@ -1410,7 +1410,7 @@ LargestIdlePrimaryChannelTest::RunOne(uint16_t chWidth, WifiChannelListType busy
// same as the previous case
Time ccaBusyRxInterval = MilliSeconds(1);
Time checkTime2 = start + ccaBusyStartDelay + ccaBusyDuration + ccaBusyRxInterval / 2;
Simulator::Schedule(checkTime2 - start, [=]() {
Simulator::Schedule(checkTime2 - start, [=, this]() {
Time interval2 = (ccaBusyDuration + ccaBusyRxInterval) / 2;
NS_TEST_EXPECT_MSG_EQ(m_cam->GetLargestIdlePrimaryChannel(interval2, checkTime2),
idleWidth,
Expand All @@ -1429,7 +1429,7 @@ LargestIdlePrimaryChannelTest::RunOne(uint16_t chWidth, WifiChannelListType busy
// At RX end, we check the status of the channel during an interval immediately
// preceding RX start and overlapping the CCA_BUSY period.
Time checkTime3 = start + ccaBusyStartDelay + ccaBusyDuration + ccaBusyRxInterval + rxDuration;
Simulator::Schedule(checkTime3 - start, [=]() {
Simulator::Schedule(checkTime3 - start, [=, this]() {
Time interval3 = ccaBusyDuration / 2 + ccaBusyRxInterval;
Time end3 = checkTime3 - rxDuration;
NS_TEST_EXPECT_MSG_EQ(m_cam->GetLargestIdlePrimaryChannel(interval3, end3),
Expand All @@ -1443,7 +1443,7 @@ LargestIdlePrimaryChannelTest::RunOne(uint16_t chWidth, WifiChannelListType busy
// At RX end, we check the status of the channel during the interval following
// the CCA_BUSY period and preceding RX start. The entire operating channel is idle.
const Time& checkTime4 = checkTime3;
Simulator::Schedule(checkTime4 - start, [=]() {
Simulator::Schedule(checkTime4 - start, [=, this]() {
const Time& interval4 = ccaBusyRxInterval;
Time end4 = checkTime4 - rxDuration;
NS_TEST_EXPECT_MSG_EQ(m_cam->GetLargestIdlePrimaryChannel(interval4, end4),
Expand All @@ -1458,7 +1458,7 @@ LargestIdlePrimaryChannelTest::RunOne(uint16_t chWidth, WifiChannelListType busy
// overlap the RX period
Time interval5 = MilliSeconds(1);
Time checkTime5 = checkTime4 + interval5;
Simulator::Schedule(checkTime5 - start, [=]() {
Simulator::Schedule(checkTime5 - start, [=, this]() {
NS_TEST_EXPECT_MSG_EQ(m_cam->GetLargestIdlePrimaryChannel(interval5, checkTime5),
chWidth,
"Incorrect width of the idle channel in an interval "
Expand All @@ -1468,7 +1468,7 @@ LargestIdlePrimaryChannelTest::RunOne(uint16_t chWidth, WifiChannelListType busy

// After RX end, no channel is idle if the interval overlaps the RX period
const Time& checkTime6 = checkTime5;
Simulator::Schedule(checkTime6 - start, [=]() {
Simulator::Schedule(checkTime6 - start, [=, this]() {
Time interval6 = interval5 + rxDuration / 2;
NS_TEST_EXPECT_MSG_EQ(m_cam->GetLargestIdlePrimaryChannel(interval6, checkTime6),
0,
Expand All @@ -1492,7 +1492,7 @@ LargestIdlePrimaryChannelTest::DoRun()

for (const auto busyChannel : busyChannels)
{
Simulator::Schedule(Seconds(delay), [this, chWidth, busyChannel]() {
Simulator::Schedule(Seconds(delay), [=, this]() {
// reset PHY
if (m_phy)
{
Expand Down
46 changes: 23 additions & 23 deletions src/wifi/test/wifi-emlsr-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ EmlsrOperationsTestBase::SetSsid(uint16_t aid, Mac48Address /* addr */)
if (m_establishBaDl)
{
// trigger establishment of BA agreement with AP as originator
Simulator::Schedule(delay, [=]() {
Simulator::Schedule(delay, [=, this]() {
m_apMac->GetDevice()->GetNode()->AddApplication(
GetApplication(DOWNLINK, aid - 1, 4, 1000));
});
Expand All @@ -364,15 +364,15 @@ EmlsrOperationsTestBase::SetSsid(uint16_t aid, Mac48Address /* addr */)
if (m_establishBaUl)
{
// trigger establishment of BA agreement with AP as recipient
Simulator::Schedule(delay, [=]() {
Simulator::Schedule(delay, [=, this]() {
m_staMacs[aid - 1]->GetDevice()->GetNode()->AddApplication(
GetApplication(UPLINK, aid - 1, 4, 1000));
});

delay += MilliSeconds(5);
}

Simulator::Schedule(delay, [=]() {
Simulator::Schedule(delay, [=, this]() {
if (aid < m_nEmlsrStations + m_nNonEmlsrStations)
{
// make the next STA start ML discovery & setup
Expand Down Expand Up @@ -853,13 +853,13 @@ EmlsrDlTxopTest::StartTraffic()
// and the generation of other packets destined to the EMLSR clients
for (std::size_t id = 0; id < m_nEmlsrStations; id++)
{
Simulator::Schedule(m_fe2to3delay + MilliSeconds(5 * (id + 1)), [=]() {
Simulator::Schedule(m_fe2to3delay + MilliSeconds(5 * (id + 1)), [=, this]() {
m_staMacs.at(id)->GetEmlsrManager()->SetAttribute(
"EmlsrLinkSet",
AttributeContainerValue<UintegerValue>({}));
});

Simulator::Schedule(m_fe2to3delay + MilliSeconds(5 * (m_nEmlsrStations + 1)), [=]() {
Simulator::Schedule(m_fe2to3delay + MilliSeconds(5 * (m_nEmlsrStations + 1)), [=, this]() {
m_apMac->GetDevice()->GetNode()->AddApplication(
GetApplication(DOWNLINK, id, 8 / m_nEmlsrStations, 650));
});
Expand All @@ -873,7 +873,7 @@ EmlsrDlTxopTest::EnableEmlsrMode()
"EmlsrLinkSet",
AttributeContainerValue<UintegerValue>(m_emlsrLinks));
m_lastAid++;
Simulator::Schedule(MilliSeconds(5), [=]() {
Simulator::Schedule(MilliSeconds(5), [=, this]() {
if (m_lastAid < m_nEmlsrStations)
{
// make the next STA send EML Notification frame
Expand Down Expand Up @@ -1652,7 +1652,7 @@ EmlsrDlTxopTest::CheckEmlNotificationFrame(Ptr<const WifiMpdu> mpdu,
ackTxVector,
phy->GetPhyBand());

Simulator::Schedule(txDuration + phy->GetSifs() + ackDuration, [=]() {
Simulator::Schedule(txDuration + phy->GetSifs() + ackDuration, [=, this]() {
if (frame.m_emlControl.emlsrMode == 1)
{
// EMLSR mode enabled. Check that all EMLSR links of the EMLSR clients are considered
Expand Down Expand Up @@ -1809,7 +1809,7 @@ EmlsrDlTxopTest::CheckInitialControlFrame(Ptr<const WifiMpdu> mpdu,
continue;
}

Simulator::Schedule(txDuration + NanoSeconds(5), [=]() {
Simulator::Schedule(txDuration + NanoSeconds(5), [=, this]() {
for (uint8_t id = 0; id < m_staMacs[i]->GetNLinks(); id++)
{
// non-EMLSR links or links on which ICF is received are not blocked
Expand Down Expand Up @@ -1858,7 +1858,7 @@ EmlsrDlTxopTest::CheckQosFrames(const WifiConstPsduMap& psduMap,
// both EMLSR clients are about to receive a QoS data frame
for (std::size_t clientId : {firstClientId, secondClientId})
{
Simulator::Schedule(txDuration, [=]() {
Simulator::Schedule(txDuration, [=, this]() {
for (uint8_t id = 0; id < m_staMacs[clientId]->GetNLinks(); id++)
{
// link on which QoS data is received is not blocked
Expand Down Expand Up @@ -1903,7 +1903,7 @@ EmlsrDlTxopTest::CheckQosFrames(const WifiConstPsduMap& psduMap,

// immediately before the end of the PPDU, this link only is not blocked for the EMLSR
// client on the AP MLD
Simulator::Schedule(txDuration - NanoSeconds(1), [=]() {
Simulator::Schedule(txDuration - NanoSeconds(1), [=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(m_apMac,
Expand All @@ -1919,7 +1919,7 @@ EmlsrDlTxopTest::CheckQosFrames(const WifiConstPsduMap& psduMap,
// immediately before the end of the PPDU, all the links on the EMLSR client that is not
// the recipient of the second QoS frame are unblocked (they are unblocked when the
// PHY-RXSTART.indication is not received)
Simulator::Schedule(txDuration - NanoSeconds(1), [=]() {
Simulator::Schedule(txDuration - NanoSeconds(1), [=, this]() {
for (uint8_t id = 0; id < m_staMacs[secondClientId]->GetNLinks(); id++)
{
CheckBlockedLink(m_staMacs[secondClientId],
Expand All @@ -1933,7 +1933,7 @@ EmlsrDlTxopTest::CheckQosFrames(const WifiConstPsduMap& psduMap,
}
});
// immediately after the end of the PPDU, all links are blocked for the EMLSR client
Simulator::Schedule(txDuration + NanoSeconds(1), [=]() {
Simulator::Schedule(txDuration + NanoSeconds(1), [=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(m_apMac,
Expand All @@ -1949,7 +1949,7 @@ EmlsrDlTxopTest::CheckQosFrames(const WifiConstPsduMap& psduMap,
// immediately before the transition delay, all links are still blocked for the EMLSR client
Simulator::Schedule(
txDuration + m_transitionDelay.at(secondClientId) - NanoSeconds(1),
[=]() {
[=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(
Expand All @@ -1967,7 +1967,7 @@ EmlsrDlTxopTest::CheckQosFrames(const WifiConstPsduMap& psduMap,
case 3:
// at the end of the third QoS frame, this link only is not blocked on the EMLSR
// client receiving the frame
Simulator::Schedule(txDuration, [=]() {
Simulator::Schedule(txDuration, [=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(m_staMacs[secondClientId],
Expand Down Expand Up @@ -2041,7 +2041,7 @@ EmlsrDlTxopTest::CheckBlockAck(const WifiConstPsduMap& psduMap,

// at the end of the PPDU, this link only is not blocked on both the EMLSR client and
// the AP MLD
Simulator::Schedule(txDuration, [=]() {
Simulator::Schedule(txDuration, [=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(m_staMacs[clientId],
Expand All @@ -2062,7 +2062,7 @@ EmlsrDlTxopTest::CheckBlockAck(const WifiConstPsduMap& psduMap,
});
// a SIFS after the end of the PPDU, still this link only is not blocked on both the
// EMLSR client and the AP MLD
Simulator::Schedule(txDuration + apPhy->GetSifs(), [=]() {
Simulator::Schedule(txDuration + apPhy->GetSifs(), [=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(m_staMacs[clientId],
Expand Down Expand Up @@ -2090,7 +2090,7 @@ EmlsrDlTxopTest::CheckBlockAck(const WifiConstPsduMap& psduMap,
case 5:
// at the end of the PPDU, this link only is not blocked on both the EMLSR client and
// the AP MLD
Simulator::Schedule(txDuration, [=]() {
Simulator::Schedule(txDuration, [=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(m_staMacs[clientId],
Expand All @@ -2113,7 +2113,7 @@ EmlsrDlTxopTest::CheckBlockAck(const WifiConstPsduMap& psduMap,
// EMLSR client and the AP MLD
Simulator::Schedule(
txDuration + apPhy->GetSifs() + cfEndTxDuration - MicroSeconds(1),
[=]() {
[=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(m_staMacs[clientId],
Expand All @@ -2136,7 +2136,7 @@ EmlsrDlTxopTest::CheckBlockAck(const WifiConstPsduMap& psduMap,
// AP MLD
Simulator::Schedule(
txDuration + apPhy->GetSifs() + cfEndTxDuration + MicroSeconds(1),
[=]() {
[=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(
Expand All @@ -2154,7 +2154,7 @@ EmlsrDlTxopTest::CheckBlockAck(const WifiConstPsduMap& psduMap,
Simulator::Schedule(
txDuration + apPhy->GetSifs() + cfEndTxDuration + m_transitionDelay.at(clientId) -
MicroSeconds(1),
[=]() {
[=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(
Expand All @@ -2171,7 +2171,7 @@ EmlsrDlTxopTest::CheckBlockAck(const WifiConstPsduMap& psduMap,
Simulator::Schedule(
txDuration + apPhy->GetSifs() + cfEndTxDuration + m_transitionDelay.at(clientId) +
MicroSeconds(1),
[=]() {
[=, this]() {
for (uint8_t id = 0; id < m_apMac->GetNLinks(); id++)
{
CheckBlockedLink(
Expand Down Expand Up @@ -2496,7 +2496,7 @@ EmlsrLinkSwitchTest::CheckInitialControlFrame(const WifiConstPsduMap& psduMap,
WifiPhy::CalculateTxDuration(psduMap, txVector, m_apMac->GetWifiPhy(linkId)->GetPhyBand());

// check that PHYs are operating on the expected link after the reception of the ICF
Simulator::Schedule(txDuration + NanoSeconds(1), [=]() {
Simulator::Schedule(txDuration + NanoSeconds(1), [=, this]() {
// the main PHY must be operating on the link where ICF was sent
NS_TEST_EXPECT_MSG_EQ(m_staMacs[0]->GetWifiPhy(linkId),
mainPhy,
Expand All @@ -2511,7 +2511,7 @@ EmlsrLinkSwitchTest::CheckInitialControlFrame(const WifiConstPsduMap& psduMap,
true,
"Aux PHY expected to switch channel");
}
Simulator::Schedule(phyRecvIcf->GetChannelSwitchDelay(), [=]() {
Simulator::Schedule(phyRecvIcf->GetChannelSwitchDelay(), [=, this]() {
NS_TEST_EXPECT_MSG_EQ(m_staMacs[0]->GetWifiPhy(*currMainPhyLinkId),
phyRecvIcf,
"The Aux PHY that received the ICF is expected to operate "
Expand Down

0 comments on commit bb491ed

Please sign in to comment.