Home | History | Annotate | Download | only in net
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef WIFICOND_NET_MLME_EVENT_H_
     18 #define WIFICOND_NET_MLME_EVENT_H_
     19 
     20 #include <memory>
     21 #include <vector>
     22 
     23 #include <android-base/macros.h>
     24 
     25 namespace android {
     26 namespace wificond {
     27 
     28 class NL80211Packet;
     29 
     30 class MlmeConnectEvent {
     31  public:
     32   static std::unique_ptr<MlmeConnectEvent> InitFromPacket(
     33       const NL80211Packet* packet);
     34   // Returns the BSSID of the associated AP.
     35   const std::vector<uint8_t>& GetBSSID() const { return bssid_; }
     36   // Get the status code of this connect event.
     37   // 0 = success, non-zero = failure.
     38   // Status codes definition: IEEE 802.11-2012, 8.4.1.9, Table 8-37
     39   uint16_t GetStatusCode() const { return status_code_; }
     40   uint32_t GetInterfaceIndex() const { return interface_index_; }
     41   bool IsTimeout() const { return is_timeout_; }
     42 
     43  private:
     44   MlmeConnectEvent() = default;
     45 
     46   uint32_t interface_index_;
     47   std::vector<uint8_t> bssid_;
     48   uint16_t status_code_;
     49   bool is_timeout_;
     50 
     51   DISALLOW_COPY_AND_ASSIGN(MlmeConnectEvent);
     52 };
     53 
     54 class MlmeAssociateEvent {
     55  public:
     56   static std::unique_ptr<MlmeAssociateEvent> InitFromPacket(
     57       const NL80211Packet* packet);
     58   // Returns the BSSID of the associated AP.
     59   const std::vector<uint8_t>& GetBSSID() const { return bssid_; }
     60   // Get the status code of this associate event.
     61   // 0 = success, non-zero = failure.
     62   // Status codes definition: IEEE 802.11-2012, 8.4.1.9, Table 8-37
     63   uint16_t GetStatusCode() const { return status_code_; }
     64   uint32_t GetInterfaceIndex() const { return interface_index_; }
     65   bool IsTimeout() const { return is_timeout_; }
     66 
     67  private:
     68   MlmeAssociateEvent() = default;
     69 
     70   uint32_t interface_index_;
     71   std::vector<uint8_t> bssid_;
     72   uint16_t status_code_;
     73   bool is_timeout_;
     74 
     75   DISALLOW_COPY_AND_ASSIGN(MlmeAssociateEvent);
     76 };
     77 
     78 class MlmeRoamEvent {
     79  public:
     80   static std::unique_ptr<MlmeRoamEvent> InitFromPacket(
     81       const NL80211Packet* packet);
     82   // Returns the BSSID of the associated AP.
     83   const std::vector<uint8_t>& GetBSSID() const { return bssid_; }
     84   uint32_t GetInterfaceIndex() const { return interface_index_; }
     85 
     86  private:
     87   MlmeRoamEvent() = default;
     88 
     89   uint32_t interface_index_;
     90   std::vector<uint8_t> bssid_;
     91 
     92   DISALLOW_COPY_AND_ASSIGN(MlmeRoamEvent);
     93 };
     94 
     95 
     96 class MlmeDisconnectEvent {
     97  public:
     98   static std::unique_ptr<MlmeDisconnectEvent> InitFromPacket(
     99       const NL80211Packet* packet);
    100   uint32_t GetInterfaceIndex() const { return interface_index_; }
    101  private:
    102   MlmeDisconnectEvent() = default;
    103 
    104   uint32_t interface_index_;
    105   std::vector<uint8_t> bssid_;
    106 
    107   DISALLOW_COPY_AND_ASSIGN(MlmeDisconnectEvent);
    108 };
    109 
    110 class MlmeDisassociateEvent {
    111  public:
    112   static std::unique_ptr<MlmeDisassociateEvent> InitFromPacket(
    113       const NL80211Packet* packet);
    114   uint32_t GetInterfaceIndex() const { return interface_index_; }
    115  private:
    116   MlmeDisassociateEvent() = default;
    117 
    118   uint32_t interface_index_;
    119   std::vector<uint8_t> bssid_;
    120 
    121   DISALLOW_COPY_AND_ASSIGN(MlmeDisassociateEvent);
    122 };
    123 
    124 }  // namespace wificond
    125 }  // namespace android
    126 
    127 #endif  // WIFICOND_NET_MLME_EVENT_H_
    128