INET Framework for OMNeT++/OMNEST
Ieee80211MgmtSTA.h
Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Andras Varga
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef IEEE80211_MGMT_STA_H
00019 #define IEEE80211_MGMT_STA_H
00020 
00021 #include <omnetpp.h>
00022 #include "Ieee80211MgmtBase.h"
00023 #include "NotificationBoard.h"
00024 #include "Ieee80211Primitives_m.h"
00025 
00026 
00033 class INET_API Ieee80211MgmtSTA : public Ieee80211MgmtBase
00034 {
00035   public:
00036     //
00037     // Encapsulates information about the ongoing scanning process
00038     //
00039     struct ScanningInfo
00040     {
00041         MACAddress bssid; // specific BSSID to scan for, or the broadcast address
00042         std::string ssid; // SSID to scan for (empty=any)
00043         bool activeScan;  // whether to perform active or passive scanning
00044         simtime_t probeDelay; // delay (in s) to be used prior to transmitting a Probe frame during active scanning
00045         std::vector<int> channelList; // list of channels to scan
00046         int currentChannelIndex; // index into channelList[]
00047         bool busyChannelDetected; // during minChannelTime, we have to listen for busy channel
00048         simtime_t minChannelTime; // minimum time to spend on each channel when scanning
00049         simtime_t maxChannelTime; // maximum time to spend on each channel when scanning
00050     };
00051 
00052     //
00053     // Stores AP info received during scanning
00054     //
00055     struct APInfo
00056     {
00057         int channel;
00058         MACAddress address; // alias bssid
00059         std::string ssid;
00060         Ieee80211SupportedRatesElement supportedRates;
00061         simtime_t beaconInterval;
00062         double rxPower;
00063 
00064         bool isAuthenticated;
00065         int authSeqExpected;  // valid while authenticating; values: 1,3,5...
00066         cMessage *authTimeoutMsg; // if non-NULL: authentication is in progress
00067 
00068         APInfo() {
00069             channel=-1; beaconInterval=rxPower=0; authSeqExpected=-1;
00070             isAuthenticated=false; authTimeoutMsg=NULL;
00071         }
00072     };
00073 
00074     //
00075     // Associated AP, plus data associated with the association with the associated AP
00076     //
00077     struct AssociatedAPInfo : public APInfo
00078     {
00079         int receiveSequence;
00080         cMessage *beaconTimeoutMsg;
00081 
00082         AssociatedAPInfo() : APInfo() {receiveSequence=0; beaconTimeoutMsg=NULL;}
00083     };
00084 
00085   protected:
00086     NotificationBoard *nb;
00087 
00088     // number of channels in ChannelControl -- used if we're told to scan "all" channels
00089     int numChannels;
00090 
00091     // scanning status
00092     bool isScanning;
00093     ScanningInfo scanning;
00094 
00095     // APInfo list: we collect scanning results and keep track of ongoing authentications here
00096     // Note: there can be several ongoing authentications simultaneously
00097     typedef std::list<APInfo> AccessPointList;
00098     AccessPointList apList;
00099 
00100     // associated Access Point
00101     bool isAssociated;
00102     cMessage *assocTimeoutMsg; // if non-NULL: association is in progress
00103     AssociatedAPInfo assocAP;
00104 
00105   protected:
00106     virtual int numInitStages() const {return 2;}
00107     virtual void initialize(int);
00108 
00110     virtual void handleTimer(cMessage *msg);
00111 
00113     virtual void handleUpperMessage(cPacket *msg);
00114 
00116     virtual void handleCommand(int msgkind, cPolymorphic *ctrl);
00117 
00119     virtual Ieee80211DataFrame *encapsulate(cPacket *msg);
00120 
00122     virtual void startAuthentication(APInfo *ap, simtime_t timeout);
00123 
00125     virtual void startAssociation(APInfo *ap, simtime_t timeout);
00126 
00128     virtual APInfo *lookupAP(const MACAddress& address);
00129 
00131     virtual void clearAPList();
00132 
00134     virtual void changeChannel(int channelNum);
00135 
00137     virtual void storeAPInfo(const MACAddress& address, const Ieee80211BeaconFrameBody& body);
00138 
00140     virtual bool scanNextChannel();
00141 
00143     virtual void sendProbeRequest();
00144 
00146     virtual void beaconLost();
00147 
00149     virtual void sendScanConfirm();
00150 
00152     virtual void sendAuthenticationConfirm(APInfo *ap, int resultCode);
00153 
00155     virtual void sendAssociationConfirm(APInfo *ap, int resultCode);
00156 
00158     virtual void disassociate();
00159 
00161     virtual void sendConfirm(Ieee80211PrimConfirm *confirm, int resultCode);
00162 
00164     virtual void sendManagementFrame(Ieee80211ManagementFrame *frame, const MACAddress& address);
00165 
00167     virtual void receiveChangeNotification(int category, const cPolymorphic *details);
00168 
00170     virtual int statusCodeToPrimResultCode(int statusCode);
00171 
00174     virtual void handleDataFrame(Ieee80211DataFrame *frame);
00175     virtual void handleAuthenticationFrame(Ieee80211AuthenticationFrame *frame);
00176     virtual void handleDeauthenticationFrame(Ieee80211DeauthenticationFrame *frame);
00177     virtual void handleAssociationRequestFrame(Ieee80211AssociationRequestFrame *frame);
00178     virtual void handleAssociationResponseFrame(Ieee80211AssociationResponseFrame *frame);
00179     virtual void handleReassociationRequestFrame(Ieee80211ReassociationRequestFrame *frame);
00180     virtual void handleReassociationResponseFrame(Ieee80211ReassociationResponseFrame *frame);
00181     virtual void handleDisassociationFrame(Ieee80211DisassociationFrame *frame);
00182     virtual void handleBeaconFrame(Ieee80211BeaconFrame *frame);
00183     virtual void handleProbeRequestFrame(Ieee80211ProbeRequestFrame *frame);
00184     virtual void handleProbeResponseFrame(Ieee80211ProbeResponseFrame *frame);
00186 
00189     virtual void processScanCommand(Ieee80211Prim_ScanRequest *ctrl);
00190     virtual void processAuthenticateCommand(Ieee80211Prim_AuthenticateRequest *ctrl);
00191     virtual void processDeauthenticateCommand(Ieee80211Prim_DeauthenticateRequest *ctrl);
00192     virtual void processAssociateCommand(Ieee80211Prim_AssociateRequest *ctrl);
00193     virtual void processReassociateCommand(Ieee80211Prim_ReassociateRequest *ctrl);
00194     virtual void processDisassociateCommand(Ieee80211Prim_DisassociateRequest *ctrl);
00196 };
00197 
00198 #endif
00199 
00200