Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Ieee80211MgmtAP Class Reference

#include <Ieee80211MgmtAP.h>

Inheritance diagram for Ieee80211MgmtAP:

Ieee80211MgmtAPBase Ieee80211MgmtBase PassiveQueueBase INotifiable IPassiveQueue List of all members.

Detailed Description

Used in 802.11 infrastructure mode: handles management frames for an access point (AP). See corresponding NED file for a detailed description.

Author:
Andras Varga


Public Types

typedef std::map< MACAddress,
STAInfo, MAC_compare
STAList
enum  STAStatus { NOT_AUTHENTICATED, AUTHENTICATED, ASSOCIATED }

Protected Member Functions

virtual int numInitStages () const
virtual void initialize (int)
virtual void handleTimer (cMessage *msg)
virtual void handleUpperMessage (cMessage *msg)
virtual void handleCommand (int msgkind, cPolymorphic *ctrl)
virtual void receiveChangeNotification (int category, cPolymorphic *details)
STAInfolookupSenderSTA (Ieee80211ManagementFrame *frame)
void sendManagementFrame (Ieee80211ManagementFrame *frame, const MACAddress &destAddr)
void sendBeacon ()
Processing of different frame types
virtual void handleDataFrame (Ieee80211DataFrame *frame)
virtual void handleAuthenticationFrame (Ieee80211AuthenticationFrame *frame)
virtual void handleDeauthenticationFrame (Ieee80211DeauthenticationFrame *frame)
virtual void handleAssociationRequestFrame (Ieee80211AssociationRequestFrame *frame)
virtual void handleAssociationResponseFrame (Ieee80211AssociationResponseFrame *frame)
virtual void handleReassociationRequestFrame (Ieee80211ReassociationRequestFrame *frame)
virtual void handleReassociationResponseFrame (Ieee80211ReassociationResponseFrame *frame)
virtual void handleDisassociationFrame (Ieee80211DisassociationFrame *frame)
virtual void handleBeaconFrame (Ieee80211BeaconFrame *frame)
virtual void handleProbeRequestFrame (Ieee80211ProbeRequestFrame *frame)
virtual void handleProbeResponseFrame (Ieee80211ProbeResponseFrame *frame)

Protected Attributes

std::string ssid
int channelNumber
simtime_t beaconInterval
int numAuthSteps
Ieee80211SupportedRatesElement supportedRates
STAList staList
 list of STAs
cMessage * beaconTimer

Classes

struct  MAC_compare
struct  STAInfo


Member Typedef Documentation

typedef std::map<MACAddress,STAInfo, MAC_compare> Ieee80211MgmtAP::STAList
 


Member Enumeration Documentation

enum Ieee80211MgmtAP::STAStatus
 

State of a STA

Enumeration values:
NOT_AUTHENTICATED 
AUTHENTICATED 
ASSOCIATED 


Member Function Documentation

void Ieee80211MgmtAP::handleAssociationRequestFrame Ieee80211AssociationRequestFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00249 {
00250     EV << "Processing AssociationRequest frame\n";
00251 
00252     // "11.3.2 AP association procedures"
00253     STAInfo *sta = lookupSenderSTA(frame);
00254     if (!sta || sta->status==NOT_AUTHENTICATED)
00255     {
00256         // STA not authenticated: send error and return
00257         Ieee80211DeauthenticationFrame *resp = new Ieee80211DeauthenticationFrame("Deauth");
00258         resp->getBody().setReasonCode(RC_NONAUTH_ASS_REQUEST);
00259         sendManagementFrame(resp, frame->getTransmitterAddress());
00260         delete frame;
00261         return;
00262     }
00263 
00264     delete frame;
00265 
00266     // mark STA as associated
00267     sta->status = ASSOCIATED; // XXX this should only take place when MAC receives the ACK for the response
00268 
00269     // send OK response
00270     Ieee80211AssociationResponseFrame *resp = new Ieee80211AssociationResponseFrame("AssocResp-OK");
00271     Ieee80211AssociationResponseFrameBody& body = resp->getBody();
00272     body.setStatusCode(SC_SUCCESSFUL);
00273     body.setAid(0); //XXX
00274     body.setSupportedRates(supportedRates);
00275     sendManagementFrame(resp, sta->address);
00276 }

void Ieee80211MgmtAP::handleAssociationResponseFrame Ieee80211AssociationResponseFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00279 {
00280     dropManagementFrame(frame);
00281 }

void Ieee80211MgmtAP::handleAuthenticationFrame Ieee80211AuthenticationFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00177 {
00178     int frameAuthSeq = frame->getBody().getSequenceNumber();
00179     EV << "Processing Authentication frame, seqNum=" << frameAuthSeq << "\n";
00180 
00181     // create STA entry if needed
00182     STAInfo *sta = lookupSenderSTA(frame);
00183     if (!sta)
00184     {
00185         MACAddress staAddress = frame->getTransmitterAddress();
00186         sta = &staList[staAddress]; // this implicitly creates a new entry
00187         sta->address = staAddress;
00188         sta->status = NOT_AUTHENTICATED;
00189         sta->authSeqExpected = 1;
00190     }
00191 
00192     // check authentication sequence number is OK
00193     if (frameAuthSeq != sta->authSeqExpected)
00194     {
00195         // wrong sequence number: send error and return
00196         EV << "Wrong sequence number, " << sta->authSeqExpected << " expected\n";
00197         Ieee80211AuthenticationFrame *resp = new Ieee80211AuthenticationFrame("Auth-ERROR");
00198         resp->getBody().setStatusCode(SC_AUTH_OUT_OF_SEQ);
00199         sendManagementFrame(resp, frame->getTransmitterAddress());
00200         delete frame;
00201         sta->authSeqExpected = 1; // go back to start square
00202         return;
00203     }
00204 
00205     // station is authenticated if it made it through the required number of steps
00206     bool isLast = (frameAuthSeq+1 == numAuthSteps);
00207 
00208     // send OK response (we don't model the cryptography part, just assume
00209     // successful authentication every time)
00210     EV << "Sending Authentication frame, seqNum=" << (frameAuthSeq+1) << "\n";
00211     Ieee80211AuthenticationFrame *resp = new Ieee80211AuthenticationFrame(isLast ? "Auth-OK" : "Auth");
00212     resp->getBody().setSequenceNumber(frameAuthSeq+1);
00213     resp->getBody().setStatusCode(SC_SUCCESSFUL);
00214     resp->getBody().setIsLast(isLast);
00215     // XXX frame length could be increased to account for challenge text length etc.
00216     sendManagementFrame(resp, frame->getTransmitterAddress());
00217 
00218     delete frame;
00219 
00220     // update status
00221     if (isLast)
00222     {
00223         sta->status = AUTHENTICATED; // XXX only when ACK of this frame arrives
00224         EV << "STA authenticated\n";
00225     }
00226     else
00227     {
00228         sta->authSeqExpected += 2;
00229         EV << "Expecting Authentication frame " << sta->authSeqExpected << "\n";
00230     }
00231 }

void Ieee80211MgmtAP::handleBeaconFrame Ieee80211BeaconFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00330 {
00331     dropManagementFrame(frame);
00332 }

void Ieee80211MgmtAP::handleCommand int  msgkind,
cPolymorphic *  ctrl
[protected, virtual]
 

Implements abstract Ieee80211MgmtBase method -- throws an error (no commands supported)

Implements Ieee80211MgmtBase.

00100 {
00101     error("handleCommand(): no commands supported");
00102 }

void Ieee80211MgmtAP::handleDataFrame Ieee80211DataFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00147 {
00148     // check toDS bit
00149     if (!frame->getToDS())
00150     {
00151         // looks like this is not for us - discard
00152         delete frame;
00153         return;
00154     }
00155 
00156     // look up destination address in our STA list
00157     STAList::iterator it = staList.find(frame->getAddress3());
00158     if (it==staList.end())
00159     {
00160         // not our STA -- pass up frame to relayUnit for LAN bridging if we have one
00161         if (hasRelayUnit)
00162             send(convertToEtherFrame(frame), "uppergateOut");
00163         else
00164             delete frame;
00165     }
00166     else
00167     {
00168         // dest address is our STA, but is it already associated?
00169         if (it->second.status == ASSOCIATED)
00170             distributeReceivedDataFrame(frame); // send it out to the destination STA
00171         else
00172             delete frame;
00173     }
00174 }

void Ieee80211MgmtAP::handleDeauthenticationFrame Ieee80211DeauthenticationFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00234 {
00235     EV << "Processing Deauthentication frame\n";
00236 
00237     STAInfo *sta = lookupSenderSTA(frame);
00238     delete frame;
00239 
00240     if (sta)
00241     {
00242         // mark STA as not authenticated; alternatively, it could also be removed from staList
00243         sta->status = NOT_AUTHENTICATED;
00244         sta->authSeqExpected = 1;
00245     }
00246 }

void Ieee80211MgmtAP::handleDisassociationFrame Ieee80211DisassociationFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00319 {
00320     STAInfo *sta = lookupSenderSTA(frame);
00321     delete frame;
00322 
00323     if (sta)
00324     {
00325         sta->status = AUTHENTICATED;
00326     }
00327 }

void Ieee80211MgmtAP::handleProbeRequestFrame Ieee80211ProbeRequestFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00335 {
00336     EV << "Processing ProbeRequest frame\n";
00337 
00338     if (strcmp(frame->getBody().getSSID(),"")!=0 && strcmp(frame->getBody().getSSID(), ssid.c_str())!=0)
00339     {
00340         EV << "SSID `" << frame->getBody().getSSID() << "' does not match, ignoring frame\n";
00341         dropManagementFrame(frame);
00342         return;
00343     }
00344 
00345     MACAddress staAddress = frame->getTransmitterAddress();
00346     delete frame;
00347 
00348     EV << "Sending ProbeResponse frame\n";
00349     Ieee80211ProbeResponseFrame *resp = new Ieee80211ProbeResponseFrame("ProbeResp");
00350     Ieee80211ProbeResponseFrameBody& body = resp->getBody();
00351     body.setSSID(ssid.c_str());
00352     body.setSupportedRates(supportedRates);
00353     body.setBeaconInterval(beaconInterval);
00354     body.setChannelNumber(channelNumber);
00355     sendManagementFrame(resp, staAddress);
00356 }

void Ieee80211MgmtAP::handleProbeResponseFrame Ieee80211ProbeResponseFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00359 {
00360     dropManagementFrame(frame);
00361 }

void Ieee80211MgmtAP::handleReassociationRequestFrame Ieee80211ReassociationRequestFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00284 {
00285     EV << "Processing ReassociationRequest frame\n";
00286 
00287     // "11.3.4 AP reassociation procedures" -- almost the same as AssociationRequest processing
00288     STAInfo *sta = lookupSenderSTA(frame);
00289     if (!sta || sta->status==NOT_AUTHENTICATED)
00290     {
00291         // STA not authenticated: send error and return
00292         Ieee80211DeauthenticationFrame *resp = new Ieee80211DeauthenticationFrame("Deauth");
00293         resp->getBody().setReasonCode(RC_NONAUTH_ASS_REQUEST);
00294         sendManagementFrame(resp, frame->getTransmitterAddress());
00295         delete frame;
00296         return;
00297     }
00298 
00299     delete frame;
00300 
00301     // mark STA as associated
00302     sta->status = ASSOCIATED; // XXX this should only take place when MAC receives the ACK for the response
00303 
00304     // send OK response
00305     Ieee80211ReassociationResponseFrame *resp = new Ieee80211ReassociationResponseFrame("ReassocResp-OK");
00306     Ieee80211ReassociationResponseFrameBody& body = resp->getBody();
00307     body.setStatusCode(SC_SUCCESSFUL);
00308     body.setAid(0); //XXX
00309     body.setSupportedRates(supportedRates);
00310     sendManagementFrame(resp, sta->address);
00311 }

void Ieee80211MgmtAP::handleReassociationResponseFrame Ieee80211ReassociationResponseFrame frame  )  [protected, virtual]
 

Implements Ieee80211MgmtBase.

00314 {
00315     dropManagementFrame(frame);
00316 }

void Ieee80211MgmtAP::handleTimer cMessage *  msg  )  [protected, virtual]
 

Implements abstract Ieee80211MgmtBase method

Implements Ieee80211MgmtBase.

00067 {
00068     if (msg==beaconTimer)
00069     {
00070         sendBeacon();
00071         scheduleAt(simTime()+beaconInterval, beaconTimer);
00072     }
00073     else
00074     {
00075         error("internal error: unrecognized timer '%s'", msg->name());
00076     }
00077 }

void Ieee80211MgmtAP::handleUpperMessage cMessage *  msg  )  [protected, virtual]
 

Implements abstract Ieee80211MgmtBase method

Implements Ieee80211MgmtBase.

00080 {
00081     // must be an EtherFrame frame arriving from MACRelayUnit, that is,
00082     // bridged from another interface of the AP (probably Ethernet).
00083     EtherFrame *etherframe = check_and_cast<EtherFrame *>(msg);
00084 
00085     // check we really have a STA with that dest address
00086     STAList::iterator it = staList.find(etherframe->getDest());
00087     if (it==staList.end() || it->second.status!=ASSOCIATED)
00088     {
00089         EV << "STA with MAC address " << etherframe->getDest() << " not associated with this AP, dropping frame\n";
00090         delete etherframe; // XXX count drops?
00091         return;
00092     }
00093 
00094     // convert Ethernet frame
00095     Ieee80211DataFrame *frame = convertFromEtherFrame(etherframe);
00096     sendOrEnqueue(frame);
00097 }

void Ieee80211MgmtAP::initialize int   )  [protected, virtual]
 

Reimplemented from Ieee80211MgmtAPBase.

00036 {
00037     Ieee80211MgmtAPBase::initialize(stage);
00038 
00039     if (stage==0)
00040     {
00041         // read params and init vars
00042         ssid = par("ssid").stringValue();
00043         beaconInterval = par("beaconInterval");
00044         numAuthSteps = par("numAuthSteps");
00045         if (numAuthSteps!=2 && numAuthSteps!=4)
00046             error("parameter 'numAuthSteps' (number of frames exchanged during authentication) must be 2 or 4, not %d", numAuthSteps);
00047         channelNumber = -1;  // value will arrive from physical layer in receiveChangeNotification()
00048         WATCH(ssid);
00049         WATCH(channelNumber);
00050         WATCH(beaconInterval);
00051         WATCH(numAuthSteps);
00052         WATCH_MAP(staList);
00053 
00054         //TBD fill in supportedRates
00055 
00056         // subscribe for notifications
00057         NotificationBoard *nb = NotificationBoardAccess().get();
00058         nb->subscribe(this, NF_RADIO_CHANNEL_CHANGED);
00059 
00060         // start beacon timer (randomize startup time)
00061         beaconTimer = new cMessage("beaconTimer");
00062         scheduleAt(uniform(0,beaconInterval), beaconTimer);
00063     }
00064 }

Ieee80211MgmtAP::STAInfo * Ieee80211MgmtAP::lookupSenderSTA Ieee80211ManagementFrame frame  )  [protected]
 

Utility function: return sender STA's entry from our STA list, or NULL if not in there

00117 {
00118     STAList::iterator it = staList.find(frame->getTransmitterAddress());
00119     return it==staList.end() ? NULL : &(it->second);
00120 }

virtual int Ieee80211MgmtAP::numInitStages  )  const [inline, protected, virtual]
 

Reimplemented from Ieee80211MgmtAPBase.

00067 {return 2;}

void Ieee80211MgmtAP::receiveChangeNotification int  category,
cPolymorphic *  details
[protected, virtual]
 

Called by the NotificationBoard whenever a change occurs we're interested in

Implements INotifiable.

00105 {
00106     Enter_Method_Silent();
00107     printNotificationBanner(category, details);
00108 
00109     if (category == NF_RADIO_CHANNEL_CHANGED)
00110     {
00111         EV << "updating channel number\n";
00112         channelNumber = check_and_cast<RadioState *>(details)->getChannelNumber();
00113     }
00114 }

void Ieee80211MgmtAP::sendBeacon  )  [protected]
 

Utility function: creates and sends a beacon frame

00131 {
00132     EV << "Sending beacon\n";
00133     Ieee80211BeaconFrame *frame = new Ieee80211BeaconFrame("Beacon");
00134     Ieee80211BeaconFrameBody& body = frame->getBody();
00135     body.setSSID(ssid.c_str());
00136     body.setSupportedRates(supportedRates);
00137     body.setBeaconInterval(beaconInterval);
00138     body.setChannelNumber(channelNumber);
00139 
00140     frame->setReceiverAddress(MACAddress::BROADCAST_ADDRESS);
00141     frame->setFromDS(true);
00142 
00143     sendOrEnqueue(frame);
00144 }

void Ieee80211MgmtAP::sendManagementFrame Ieee80211ManagementFrame frame,
const MACAddress destAddr
[protected]
 

Utility function: set fields in the given frame and send it out to the address

00123 {
00124     frame->setFromDS(true);
00125     frame->setReceiverAddress(destAddr);
00126     frame->setAddress3(myAddress);
00127     sendOrEnqueue(frame);
00128 }


Member Data Documentation

simtime_t Ieee80211MgmtAP::beaconInterval [protected]
 

cMessage* Ieee80211MgmtAP::beaconTimer [protected]
 

int Ieee80211MgmtAP::channelNumber [protected]
 

int Ieee80211MgmtAP::numAuthSteps [protected]
 

std::string Ieee80211MgmtAP::ssid [protected]
 

STAList Ieee80211MgmtAP::staList [protected]
 

list of STAs

Ieee80211SupportedRatesElement Ieee80211MgmtAP::supportedRates [protected]
 


The documentation for this class was generated from the following files:
Generated on Thu Oct 19 18:22:23 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.0