Skip to content

Commit

Permalink
Merge branch 'inetmanet-2.2' of github.com:aarizaq/inetmanet-2.0 into…
Browse files Browse the repository at this point in the history
… inetmanet-2.2
  • Loading branch information
aarizaq committed Apr 1, 2014
2 parents 370cbd1 + c3882f1 commit 8a8225c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
42 changes: 42 additions & 0 deletions src/linklayer/ieee80211/mgmt/Ieee80211AgentSTA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void Ieee80211AgentSTA::initialize(int stage)
scheduleAt(simTime()+startingTime, new cMessage("startUp", MK_STARTUP));

myIface = NULL;
isOperational = true;
}
else if (stage == 1)
{
Expand All @@ -75,6 +76,9 @@ void Ieee80211AgentSTA::initialize(int stage)

void Ieee80211AgentSTA::handleMessage(cMessage *msg)
{
if (!isOperational)
delete msg;

if (msg->isSelfMessage())
handleTimer(msg);
else
Expand Down Expand Up @@ -122,6 +126,9 @@ void Ieee80211AgentSTA::receiveChangeNotification(int category, const cObject *d
Enter_Method_Silent();
printNotificationBanner(category, details);

if (!isOperational)
return;

if (category == NF_L2_BEACON_LOST)
{
//XXX should check details if it's about this NIC
Expand Down Expand Up @@ -347,3 +354,38 @@ void Ieee80211AgentSTA::processReassociateConfirm(Ieee80211Prim_ReassociateConfi
}
}

bool Ieee80211AgentSTA::handleOperationStage(LifecycleOperation *operation, int stage, IDoneCallback *doneCallback)
{
Enter_Method_Silent();
if (dynamic_cast<NodeStartOperation *>(operation)) {
if (stage == NodeStartOperation::STAGE_PHYSICAL_LAYER)
start();
}
else if (dynamic_cast<NodeShutdownOperation *>(operation)) {
if (stage == NodeStartOperation::STAGE_PHYSICAL_LAYER)
stop();
}
else if (dynamic_cast<NodeCrashOperation *>(operation)) {
if (stage == NodeStartOperation::STAGE_LOCAL) // crash is immediate
stop();
}
else
throw cRuntimeError("Unsupported operation '%s'", operation->getClassName());
return true;
}

void Ieee80211AgentSTA::start()
{
isOperational = true;
simtime_t startingTime = uniform(SIMTIME_ZERO, maxChannelTime);
scheduleAt(simTime()+startingTime, new cMessage("startUp", MK_STARTUP));
}

void Ieee80211AgentSTA::stop()
{
clear();
dataQueue.clear();
emit(dataQueueLenSignal, dataQueue.length());
mgmtQueue.clear();
isOperational = false;
}
12 changes: 11 additions & 1 deletion src/linklayer/ieee80211/mgmt/Ieee80211AgentSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "Ieee80211Primitives_m.h"
#include "NotificationBoard.h"
#include "InterfaceTable.h"
#include "ILifecycle.h"


/**
Expand All @@ -36,9 +37,10 @@
*
* @author Andras Varga
*/
class INET_API Ieee80211AgentSTA : public cSimpleModule, public INotifiable
class INET_API Ieee80211AgentSTA : public cSimpleModule, public INotifiable, public ILifecycle
{
protected:
bool isOperational; // for lifecycle
InterfaceEntry *myIface;
NotificationBoard *nb;
MACAddress prevAP;
Expand Down Expand Up @@ -102,6 +104,14 @@ class INET_API Ieee80211AgentSTA : public cSimpleModule, public INotifiable

// utility method, for debugging
virtual void dumpAPList(Ieee80211Prim_ScanConfirm *resp);
/** lifecycle support */
//@{
protected:
virtual void start();
virtual void stop();
public:
virtual bool handleOperationStage(LifecycleOperation *operation, int stage, IDoneCallback *doneCallback);
//@}
};

#endif
Expand Down

0 comments on commit 8a8225c

Please sign in to comment.