Ieee80211TesterMac.cc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // Copyright (C) 2015 Andras Varga
  3. //
  4. // This program is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU Lesser General Public License
  6. // as published by the Free Software Foundation; either version 2
  7. // of the License, or (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with this program; if not, see http://www.gnu.org/licenses/.
  16. //
  17. //
  18. #include "Ieee80211TesterMac.h"
  19. #include "inet/linklayer/ieee80211/mac/Ieee80211Frame_m.h"
  20. #include "inet/linklayer/ieee80211/mac/contract/IRx.h"
  21. namespace inet {
  22. Define_Module(Ieee80211TesterMac);
  23. void Ieee80211TesterMac::handleLowerPacket(cPacket *msg)
  24. {
  25. actions = par("actions").stringValue();
  26. int len = strlen(actions);
  27. if (msgCounter >= len)
  28. throw cRuntimeError("No action is defined for this msg %s", msg->getName());
  29. if (actions[msgCounter] == 'A') {
  30. auto frame = check_and_cast<Ieee80211Frame *>(msg);
  31. if (rx->lowerFrameReceived(frame))
  32. processLowerFrame(frame);
  33. else { // corrupted frame received
  34. if (qosSta)
  35. hcf->corruptedFrameReceived();
  36. else
  37. dcf->corruptedFrameReceived();
  38. }
  39. }
  40. else if (actions[msgCounter] == 'B')
  41. delete msg; // block
  42. else
  43. throw cRuntimeError("Unknown action = %c", actions[msgCounter]);
  44. msgCounter++;
  45. }
  46. } // namespace inet