#include <Ieee80211MgmtAP.h>
Inheritance diagram for Ieee80211MgmtAP:

|
|
|
|
|
State of a STA 00038 {NOT_AUTHENTICATED, AUTHENTICATED, ASSOCIATED};
|
|
|
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 }
|
|
|
Implements Ieee80211MgmtBase. 00279 {
00280 dropManagementFrame(frame);
00281 }
|
|
|
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 }
|
|
|
Implements Ieee80211MgmtBase. 00330 {
00331 dropManagementFrame(frame);
00332 }
|
|
||||||||||||
|
Implements abstract Ieee80211MgmtBase method -- throws an error (no commands supported) Implements Ieee80211MgmtBase. 00100 {
00101 error("handleCommand(): no commands supported");
00102 }
|
|
|
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 }
|
|
|
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 }
|
|
|
Implements Ieee80211MgmtBase. 00319 {
00320 STAInfo *sta = lookupSenderSTA(frame);
00321 delete frame;
00322
00323 if (sta)
00324 {
00325 sta->status = AUTHENTICATED;
00326 }
00327 }
|
|
|
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 }
|
|
|
Implements Ieee80211MgmtBase. 00359 {
00360 dropManagementFrame(frame);
00361 }
|
|
|
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 }
|
|
|
Implements Ieee80211MgmtBase. 00314 {
00315 dropManagementFrame(frame);
00316 }
|
|
|
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 }
|
|
|
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 }
|
|
|
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 }
|
|
|
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 }
|
|
|
Reimplemented from Ieee80211MgmtAPBase. 00067 {return 2;}
|
|
||||||||||||
|
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 }
|
|
|
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 }
|
|
||||||||||||
|
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 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list of STAs
|
|
|
|
1.4.0