|
8 | 8 | #include "inet/common/ModuleAccess.h" |
9 | 9 | #include "inet/common/Simsignals.h" |
10 | 10 | #include "inet/linklayer/common/MacAddressTag_m.h" |
11 | | - |
12 | 11 | #ifdef INET_WITH_ETHERNET |
13 | 12 | #include "inet/linklayer/ethernet/common/EthernetMacHeader_m.h" |
14 | 13 | #endif // ifdef INET_WITH_ETHERNET |
15 | 14 |
|
| 15 | +#include "inet/linklayer/ieee80211/mac/contract/IFrameSequenceHandler.h" |
| 16 | +#include "inet/linklayer/ieee80211/mac/framesequence/FrameSequenceContext.h" |
16 | 17 | #include "inet/linklayer/ieee80211/mac/Ieee80211Frame_m.h" |
17 | 18 | #include "inet/linklayer/ieee80211/mac/Ieee80211SubtypeTag_m.h" |
18 | 19 | #include "inet/linklayer/ieee80211/mgmt/Ieee80211MgmtAp.h" |
| 20 | +#include "inet/networklayer/common/NetworkInterface.h" |
19 | 21 | #include "inet/physicallayer/wireless/ieee80211/packetlevel/Ieee80211Radio.h" |
20 | 22 |
|
21 | 23 | namespace inet { |
@@ -61,6 +63,7 @@ void Ieee80211MgmtAp::initialize(int stage) |
61 | 63 | // subscribe for notifications |
62 | 64 | cModule *radioModule = getModuleFromPar<cModule>(par("radioModule"), this); |
63 | 65 | radioModule->subscribe(Ieee80211Radio::radioChannelChangedSignal, this); |
| 66 | + getContainingNicModule(this)->subscribe(IFrameSequenceHandler::frameSequenceFinishedSignal, this); |
64 | 67 |
|
65 | 68 | // start beacon timer (randomize startup time) |
66 | 69 | beaconTimer = new cMessage("beaconTimer"); |
@@ -93,6 +96,34 @@ void Ieee80211MgmtAp::receiveSignal(cComponent *source, simsignal_t signalID, in |
93 | 96 | } |
94 | 97 | } |
95 | 98 |
|
| 99 | +void Ieee80211MgmtAp::receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) |
| 100 | +{ |
| 101 | + Enter_Method("%s", cComponent::getSignalName(signalID)); |
| 102 | + |
| 103 | + if (signalID == IFrameSequenceHandler::frameSequenceFinishedSignal) { |
| 104 | + auto context = check_and_cast<FrameSequenceContext *>(obj); |
| 105 | + if (context->getNumSteps() >= 2) { |
| 106 | + auto transmitStep = dynamic_cast<ITransmitStep *>(context->getStepBeforeLast()); |
| 107 | + auto receiveStep = dynamic_cast<IReceiveStep *>(context->getLastStep()); |
| 108 | + if (transmitStep && receiveStep && |
| 109 | + transmitStep->getCompletion() == IFrameSequenceStep::Completion::ACCEPTED && |
| 110 | + receiveStep->getCompletion() == IFrameSequenceStep::Completion::ACCEPTED) { |
| 111 | + auto responseHeader = dynamicPtrCast<const Ieee80211MgmtHeader>(transmitStep->getFrameToTransmit()->peekAtFront<Ieee80211MacHeader>()); |
| 112 | + if (responseHeader != nullptr && (responseHeader->getType() == ST_ASSOCIATIONRESPONSE || responseHeader->getType() == ST_REASSOCIATIONRESPONSE)) { |
| 113 | + auto ackHeader = receiveStep->getReceivedFrame()->peekAtFront<Ieee80211MacHeader>(); |
| 114 | + if (ackHeader->getType() == ST_ACK) { |
| 115 | + if (responseHeader->getType() == ST_ASSOCIATIONRESPONSE && mib->bssAccessPointData.stations[responseHeader->getReceiverAddress()] != Ieee80211Mib::ASSOCIATED) |
| 116 | + sendAssocNotification(responseHeader->getReceiverAddress()); |
| 117 | + mib->bssAccessPointData.stations[responseHeader->getReceiverAddress()] = Ieee80211Mib::ASSOCIATED; |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | + else |
| 124 | + Ieee80211MgmtApBase::receiveSignal(source, signalID, obj, details); |
| 125 | +} |
| 126 | + |
96 | 127 | Ieee80211MgmtAp::StaInfo *Ieee80211MgmtAp::lookupSenderSTA(const Ptr<const Ieee80211MgmtHeader>& header) |
97 | 128 | { |
98 | 129 | auto it = staList.find(header->getTransmitterAddress()); |
@@ -229,11 +260,6 @@ void Ieee80211MgmtAp::handleAssociationRequestFrame(Packet *packet, const Ptr<co |
229 | 260 |
|
230 | 261 | delete packet; |
231 | 262 |
|
232 | | - // mark STA as associated |
233 | | - if (mib->bssAccessPointData.stations[sta->address] != Ieee80211Mib::ASSOCIATED) |
234 | | - sendAssocNotification(sta->address); |
235 | | - mib->bssAccessPointData.stations[sta->address] = Ieee80211Mib::ASSOCIATED; // TODO this should only take place when MAC receives the ACK for the response |
236 | | - |
237 | 263 | // send OK response |
238 | 264 | const auto& body = makeShared<Ieee80211AssociationResponseFrame>(); |
239 | 265 | body->setStatusCode(SC_SUCCESSFUL); |
@@ -265,9 +291,6 @@ void Ieee80211MgmtAp::handleReassociationRequestFrame(Packet *packet, const Ptr< |
265 | 291 |
|
266 | 292 | delete packet; |
267 | 293 |
|
268 | | - // mark STA as associated |
269 | | - mib->bssAccessPointData.stations[sta->address] = Ieee80211Mib::ASSOCIATED; // TODO this should only take place when MAC receives the ACK for the response |
270 | | - |
271 | 294 | // send OK response |
272 | 295 | const auto& body = makeShared<Ieee80211ReassociationResponseFrame>(); |
273 | 296 | body->setStatusCode(SC_SUCCESSFUL); |
|
0 commit comments