Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Wade Guthrie | 89e6cb3 | 2013-03-07 08:03:45 -0800 | [diff] [blame] | 5 | #ifndef SHILL_NL80211_MESSAGE_H_ |
| 6 | #define SHILL_NL80211_MESSAGE_H_ |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 7 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 8 | #include <map> |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 9 | #include <string> |
Wade Guthrie | 8343f7f | 2012-12-04 13:52:32 -0800 | [diff] [blame] | 10 | #include <vector> |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 11 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 12 | #include <base/lazy_instance.h> |
Wade Guthrie | 89e6cb3 | 2013-03-07 08:03:45 -0800 | [diff] [blame] | 13 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 14 | #include "shill/byte_string.h" |
Wade Guthrie | 0ae4b8e | 2013-04-10 16:49:15 -0700 | [diff] [blame] | 15 | #include "shill/generic_netlink_message.h" |
Wade Guthrie | 1619624 | 2012-11-20 15:53:52 -0800 | [diff] [blame] | 16 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 17 | struct nlmsghdr; |
| 18 | |
| 19 | namespace shill { |
| 20 | |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 21 | // Class for messages received from the mac80211 drivers by way of the |
| 22 | // cfg80211 kernel module. |
| 23 | class Nl80211Message : public GenericNetlinkMessage { |
| 24 | public: |
| 25 | static const char kMessageTypeString[]; |
| 26 | static const unsigned int kEthernetAddressBytes; |
| 27 | static const char kBogusMacAddress[]; |
| 28 | |
| 29 | Nl80211Message(uint8 command, const char *command_string) |
| 30 | : GenericNetlinkMessage(nl80211_message_type_, command, command_string) {} |
| 31 | virtual ~Nl80211Message() {} |
| 32 | |
Paul Stewart | 2ddf2c6 | 2013-04-16 09:47:34 -0700 | [diff] [blame] | 33 | // Gets the family_id / message_type for all Nl80211 messages. |
| 34 | static uint16_t GetMessageType(); |
| 35 | |
Wade Guthrie | bee87c2 | 2013-03-06 11:00:46 -0800 | [diff] [blame] | 36 | // Sets the family_id / message_type for all Nl80211 messages. |
| 37 | static void SetMessageType(uint16_t message_type); |
| 38 | |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 39 | virtual bool InitFromNlmsg(const nlmsghdr *msg); |
| 40 | |
| 41 | uint8 command() const { return command_; } |
| 42 | const char *command_string() const { return command_string_; } |
| 43 | uint16_t message_type() const { return message_type_; } |
| 44 | uint32_t sequence_number() const { return sequence_number_; } |
| 45 | void set_sequence_number(uint32_t seq) { sequence_number_ = seq; } |
| 46 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 47 | // TODO(wdg): This needs to be moved to AttributeMac. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 48 | // Helper function to provide a string for a MAC address. If no attribute |
| 49 | // is found, this method returns 'false'. On any error with a non-NULL |
| 50 | // |value|, this method sets |value| to a bogus MAC address. |
Wade Guthrie | 68da97c | 2013-02-26 13:09:35 -0800 | [diff] [blame] | 51 | bool GetMacAttributeString(int id, std::string *value) const; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 52 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 53 | // TODO(wdg): This needs to be moved to AttributeScanFrequencies. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 54 | // Helper function to provide a vector of scan frequencies for attributes |
| 55 | // that contain them (such as NL80211_ATTR_SCAN_FREQUENCIES). |
Wade Guthrie | 68da97c | 2013-02-26 13:09:35 -0800 | [diff] [blame] | 56 | bool GetScanFrequenciesAttribute(int id, std::vector<uint32_t> *value) const; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 57 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 58 | // TODO(wdg): This needs to be moved to AttributeScanSSids. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 59 | // Helper function to provide a vector of SSIDs for attributes that contain |
| 60 | // them (such as NL80211_ATTR_SCAN_SSIDS). |
Wade Guthrie | 68da97c | 2013-02-26 13:09:35 -0800 | [diff] [blame] | 61 | bool GetScanSsidsAttribute(int id, std::vector<std::string> *value) const; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 62 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 63 | // TODO(wdg): This needs to be moved to AttributeMac. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 64 | // Stringizes the MAC address found in 'arg'. If there are problems (such |
| 65 | // as a NULL |arg|), |value| is set to a bogus MAC address. |
| 66 | static std::string StringFromMacAddress(const uint8_t *arg); |
| 67 | |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 68 | // Returns a string representing the passed-in |status| or |reason|, the |
| 69 | // value of which has been acquired from libnl (for example, from the |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 70 | // NL80211_ATTR_STATUS_CODE or NL80211_ATTR_REASON_CODE attribute). |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 71 | static std::string StringFromReason(uint16_t reason); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 72 | static std::string StringFromStatus(uint16_t status); |
| 73 | |
Wade Guthrie | 12f113a | 2013-03-12 17:15:46 -0700 | [diff] [blame] | 74 | // Message factory for all types of Nl80211 message. |
| 75 | static NetlinkMessage *CreateMessage(const nlmsghdr *const_msg); |
| 76 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 77 | private: |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 78 | static std::map<uint16_t, std::string> *reason_code_string_; |
| 79 | static std::map<uint16_t, std::string> *status_code_string_; |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 80 | static uint16_t nl80211_message_type_; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 81 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 82 | DISALLOW_COPY_AND_ASSIGN(Nl80211Message); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | class Nl80211Frame { |
| 86 | public: |
| 87 | enum Type { |
| 88 | kAssocResponseFrameType = 0x10, |
| 89 | kReassocResponseFrameType = 0x30, |
| 90 | kAssocRequestFrameType = 0x00, |
| 91 | kReassocRequestFrameType = 0x20, |
| 92 | kAuthFrameType = 0xb0, |
| 93 | kDisassocFrameType = 0xa0, |
| 94 | kDeauthFrameType = 0xc0, |
| 95 | kIllegalFrameType = 0xff |
| 96 | }; |
| 97 | |
repo sync | d316eb7 | 2012-12-10 15:48:47 -0800 | [diff] [blame] | 98 | explicit Nl80211Frame(const ByteString &init); |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 99 | bool ToString(std::string *output) const; |
| 100 | bool IsEqual(const Nl80211Frame &other) const; |
| 101 | uint16_t reason() const { return reason_; } |
| 102 | uint16_t status() const { return status_; } |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 103 | |
| 104 | private: |
| 105 | static const uint8_t kMinimumFrameByteCount; |
| 106 | static const uint8_t kFrameTypeMask; |
| 107 | |
| 108 | std::string mac_from_; |
| 109 | std::string mac_to_; |
| 110 | uint8_t frame_type_; |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 111 | uint16_t reason_; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 112 | uint16_t status_; |
Wade Guthrie | 8343f7f | 2012-12-04 13:52:32 -0800 | [diff] [blame] | 113 | ByteString frame_; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 114 | |
| 115 | DISALLOW_COPY_AND_ASSIGN(Nl80211Frame); |
| 116 | }; |
| 117 | |
| 118 | // |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 119 | // Specific Nl80211Message types. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 120 | // |
| 121 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 122 | class AssociateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 123 | public: |
| 124 | static const uint8_t kCommand; |
| 125 | static const char kCommandString[]; |
| 126 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 127 | AssociateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 128 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 129 | private: |
| 130 | DISALLOW_COPY_AND_ASSIGN(AssociateMessage); |
| 131 | }; |
| 132 | |
| 133 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 134 | class AuthenticateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 135 | public: |
| 136 | static const uint8_t kCommand; |
| 137 | static const char kCommandString[]; |
| 138 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 139 | AuthenticateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 140 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 141 | private: |
| 142 | DISALLOW_COPY_AND_ASSIGN(AuthenticateMessage); |
| 143 | }; |
| 144 | |
| 145 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 146 | class CancelRemainOnChannelMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 147 | public: |
| 148 | static const uint8_t kCommand; |
| 149 | static const char kCommandString[]; |
| 150 | |
Christopher Wiley | 764538d | 2012-11-09 10:58:23 -0800 | [diff] [blame] | 151 | CancelRemainOnChannelMessage() |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 152 | : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 153 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 154 | private: |
| 155 | DISALLOW_COPY_AND_ASSIGN(CancelRemainOnChannelMessage); |
| 156 | }; |
| 157 | |
| 158 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 159 | class ConnectMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 160 | public: |
| 161 | static const uint8_t kCommand; |
| 162 | static const char kCommandString[]; |
| 163 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 164 | ConnectMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 165 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 166 | private: |
| 167 | DISALLOW_COPY_AND_ASSIGN(ConnectMessage); |
| 168 | }; |
| 169 | |
| 170 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 171 | class DeauthenticateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 172 | public: |
| 173 | static const uint8_t kCommand; |
| 174 | static const char kCommandString[]; |
| 175 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 176 | DeauthenticateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 177 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 178 | private: |
| 179 | DISALLOW_COPY_AND_ASSIGN(DeauthenticateMessage); |
| 180 | }; |
| 181 | |
| 182 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 183 | class DeleteStationMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 184 | public: |
| 185 | static const uint8_t kCommand; |
| 186 | static const char kCommandString[]; |
| 187 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 188 | DeleteStationMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 189 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 190 | private: |
| 191 | DISALLOW_COPY_AND_ASSIGN(DeleteStationMessage); |
| 192 | }; |
| 193 | |
| 194 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 195 | class DisassociateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 196 | public: |
| 197 | static const uint8_t kCommand; |
| 198 | static const char kCommandString[]; |
| 199 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 200 | DisassociateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 201 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 202 | private: |
| 203 | DISALLOW_COPY_AND_ASSIGN(DisassociateMessage); |
| 204 | }; |
| 205 | |
| 206 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 207 | class DisconnectMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 208 | public: |
| 209 | static const uint8_t kCommand; |
| 210 | static const char kCommandString[]; |
| 211 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 212 | DisconnectMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 213 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 214 | private: |
| 215 | DISALLOW_COPY_AND_ASSIGN(DisconnectMessage); |
| 216 | }; |
| 217 | |
| 218 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 219 | class FrameTxStatusMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 220 | public: |
| 221 | static const uint8_t kCommand; |
| 222 | static const char kCommandString[]; |
| 223 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 224 | FrameTxStatusMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 225 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 226 | private: |
| 227 | DISALLOW_COPY_AND_ASSIGN(FrameTxStatusMessage); |
| 228 | }; |
| 229 | |
repo sync | 0efa9f0 | 2012-12-28 13:40:20 -0800 | [diff] [blame] | 230 | class GetRegMessage : public Nl80211Message { |
| 231 | public: |
| 232 | static const uint8_t kCommand; |
| 233 | static const char kCommandString[]; |
| 234 | |
| 235 | GetRegMessage() : Nl80211Message(kCommand, kCommandString) {} |
| 236 | |
| 237 | private: |
| 238 | DISALLOW_COPY_AND_ASSIGN(GetRegMessage); |
| 239 | }; |
| 240 | |
Wade Guthrie | 1f355e8 | 2013-04-11 15:46:12 -0700 | [diff] [blame] | 241 | class GetWiphyMessage : public Nl80211Message { |
| 242 | public: |
| 243 | static const uint8_t kCommand; |
| 244 | static const char kCommandString[]; |
| 245 | |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 246 | GetWiphyMessage(); |
Wade Guthrie | 1f355e8 | 2013-04-11 15:46:12 -0700 | [diff] [blame] | 247 | |
| 248 | private: |
| 249 | DISALLOW_COPY_AND_ASSIGN(GetWiphyMessage); |
| 250 | }; |
| 251 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 252 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 253 | class JoinIbssMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 254 | public: |
| 255 | static const uint8_t kCommand; |
| 256 | static const char kCommandString[]; |
| 257 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 258 | JoinIbssMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 259 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 260 | private: |
| 261 | DISALLOW_COPY_AND_ASSIGN(JoinIbssMessage); |
| 262 | }; |
| 263 | |
| 264 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 265 | class MichaelMicFailureMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 266 | public: |
| 267 | static const uint8_t kCommand; |
| 268 | static const char kCommandString[]; |
| 269 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 270 | MichaelMicFailureMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 271 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 272 | private: |
| 273 | DISALLOW_COPY_AND_ASSIGN(MichaelMicFailureMessage); |
| 274 | }; |
| 275 | |
| 276 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 277 | class NewScanResultsMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 278 | public: |
| 279 | static const uint8_t kCommand; |
| 280 | static const char kCommandString[]; |
| 281 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 282 | NewScanResultsMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 283 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 284 | private: |
| 285 | DISALLOW_COPY_AND_ASSIGN(NewScanResultsMessage); |
| 286 | }; |
| 287 | |
| 288 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 289 | class NewStationMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 290 | public: |
| 291 | static const uint8_t kCommand; |
| 292 | static const char kCommandString[]; |
| 293 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 294 | NewStationMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 295 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 296 | private: |
| 297 | DISALLOW_COPY_AND_ASSIGN(NewStationMessage); |
| 298 | }; |
| 299 | |
| 300 | |
Wade Guthrie | 1f355e8 | 2013-04-11 15:46:12 -0700 | [diff] [blame] | 301 | class NewWiphyMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 302 | public: |
| 303 | static const uint8_t kCommand; |
| 304 | static const char kCommandString[]; |
| 305 | |
Wade Guthrie | 1f355e8 | 2013-04-11 15:46:12 -0700 | [diff] [blame] | 306 | NewWiphyMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 307 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 308 | private: |
Wade Guthrie | 1f355e8 | 2013-04-11 15:46:12 -0700 | [diff] [blame] | 309 | DISALLOW_COPY_AND_ASSIGN(NewWiphyMessage); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 313 | class NotifyCqmMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 314 | public: |
| 315 | static const uint8_t kCommand; |
| 316 | static const char kCommandString[]; |
| 317 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 318 | NotifyCqmMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 319 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 320 | private: |
| 321 | DISALLOW_COPY_AND_ASSIGN(NotifyCqmMessage); |
| 322 | }; |
| 323 | |
| 324 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 325 | class PmksaCandidateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 326 | public: |
| 327 | static const uint8_t kCommand; |
| 328 | static const char kCommandString[]; |
| 329 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 330 | PmksaCandidateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 331 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 332 | private: |
| 333 | DISALLOW_COPY_AND_ASSIGN(PmksaCandidateMessage); |
| 334 | }; |
| 335 | |
| 336 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 337 | class RegBeaconHintMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 338 | public: |
| 339 | static const uint8_t kCommand; |
| 340 | static const char kCommandString[]; |
| 341 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 342 | RegBeaconHintMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 343 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 344 | private: |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 345 | DISALLOW_COPY_AND_ASSIGN(RegBeaconHintMessage); |
| 346 | }; |
| 347 | |
| 348 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 349 | class RegChangeMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 350 | public: |
| 351 | static const uint8_t kCommand; |
| 352 | static const char kCommandString[]; |
| 353 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 354 | RegChangeMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 355 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 356 | private: |
| 357 | DISALLOW_COPY_AND_ASSIGN(RegChangeMessage); |
| 358 | }; |
| 359 | |
| 360 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 361 | class RemainOnChannelMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 362 | public: |
| 363 | static const uint8_t kCommand; |
| 364 | static const char kCommandString[]; |
| 365 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 366 | RemainOnChannelMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 367 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 368 | private: |
| 369 | DISALLOW_COPY_AND_ASSIGN(RemainOnChannelMessage); |
| 370 | }; |
| 371 | |
| 372 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 373 | class RoamMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 374 | public: |
| 375 | static const uint8_t kCommand; |
| 376 | static const char kCommandString[]; |
| 377 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 378 | RoamMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 379 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 380 | private: |
| 381 | DISALLOW_COPY_AND_ASSIGN(RoamMessage); |
| 382 | }; |
| 383 | |
| 384 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 385 | class ScanAbortedMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 386 | public: |
| 387 | static const uint8_t kCommand; |
| 388 | static const char kCommandString[]; |
| 389 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 390 | ScanAbortedMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 391 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 392 | private: |
| 393 | DISALLOW_COPY_AND_ASSIGN(ScanAbortedMessage); |
| 394 | }; |
| 395 | |
| 396 | |
Wade Guthrie | 7187247 | 2013-03-05 10:33:38 -0800 | [diff] [blame] | 397 | class GetScanMessage : public Nl80211Message { |
| 398 | public: |
| 399 | static const uint8_t kCommand; |
| 400 | static const char kCommandString[]; |
| 401 | |
| 402 | GetScanMessage() : Nl80211Message(kCommand, kCommandString) {} |
| 403 | |
| 404 | private: |
| 405 | DISALLOW_COPY_AND_ASSIGN(GetScanMessage); |
| 406 | }; |
| 407 | |
| 408 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 409 | class TriggerScanMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 410 | public: |
| 411 | static const uint8_t kCommand; |
| 412 | static const char kCommandString[]; |
| 413 | |
Wade Guthrie | b9c3feb | 2013-04-25 16:31:19 -0700 | [diff] [blame] | 414 | TriggerScanMessage(); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 415 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 416 | private: |
| 417 | DISALLOW_COPY_AND_ASSIGN(TriggerScanMessage); |
| 418 | }; |
| 419 | |
| 420 | |
Wade Guthrie | 40d992c | 2013-04-19 11:10:11 -0700 | [diff] [blame] | 421 | class UnknownNl80211Message : public Nl80211Message { |
| 422 | public: |
| 423 | explicit UnknownNl80211Message(uint8_t command) |
| 424 | : Nl80211Message(command, "<UNKNOWN NL80211 MESSAGE>"), |
| 425 | command_(command) {} |
| 426 | |
| 427 | private: |
| 428 | uint8_t command_; |
| 429 | DISALLOW_COPY_AND_ASSIGN(UnknownNl80211Message); |
| 430 | }; |
| 431 | |
| 432 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 433 | class UnprotDeauthenticateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 434 | public: |
| 435 | static const uint8_t kCommand; |
| 436 | static const char kCommandString[]; |
| 437 | |
Christopher Wiley | 764538d | 2012-11-09 10:58:23 -0800 | [diff] [blame] | 438 | UnprotDeauthenticateMessage() |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 439 | : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 440 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 441 | private: |
| 442 | DISALLOW_COPY_AND_ASSIGN(UnprotDeauthenticateMessage); |
| 443 | }; |
| 444 | |
| 445 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 446 | class UnprotDisassociateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 447 | public: |
| 448 | static const uint8_t kCommand; |
| 449 | static const char kCommandString[]; |
| 450 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 451 | UnprotDisassociateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 452 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 453 | private: |
| 454 | DISALLOW_COPY_AND_ASSIGN(UnprotDisassociateMessage); |
| 455 | }; |
| 456 | |
Paul Stewart | 2ddf2c6 | 2013-04-16 09:47:34 -0700 | [diff] [blame] | 457 | |
| 458 | class GetInterfaceMessage : public Nl80211Message { |
| 459 | public: |
| 460 | static const uint8_t kCommand; |
| 461 | static const char kCommandString[]; |
| 462 | |
| 463 | GetInterfaceMessage(); |
| 464 | |
| 465 | private: |
| 466 | DISALLOW_COPY_AND_ASSIGN(GetInterfaceMessage); |
| 467 | }; |
| 468 | |
| 469 | class NewInterfaceMessage : public Nl80211Message { |
| 470 | public: |
| 471 | static const uint8_t kCommand; |
| 472 | static const char kCommandString[]; |
| 473 | |
| 474 | NewInterfaceMessage() : Nl80211Message(kCommand, kCommandString) {} |
| 475 | |
| 476 | private: |
| 477 | DISALLOW_COPY_AND_ASSIGN(NewInterfaceMessage); |
| 478 | }; |
| 479 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 480 | // Nl80211MessageDataCollector - this class is used to collect data to be |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 481 | // used for unit tests. It is only invoked in this case. |
| 482 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 483 | class Nl80211MessageDataCollector { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 484 | public: |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 485 | static Nl80211MessageDataCollector *GetInstance(); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 486 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 487 | void CollectDebugData(const Nl80211Message &message, nlmsghdr *msg); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 488 | |
| 489 | protected: |
| 490 | friend struct |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 491 | base::DefaultLazyInstanceTraits<Nl80211MessageDataCollector>; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 492 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 493 | explicit Nl80211MessageDataCollector(); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 494 | |
| 495 | private: |
| 496 | // In order to limit the output from this class, I keep track of types I |
| 497 | // haven't yet printed. |
| 498 | std::map<uint8_t, bool> need_to_print; |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 499 | |
| 500 | DISALLOW_COPY_AND_ASSIGN(Nl80211MessageDataCollector); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 501 | }; |
| 502 | |
| 503 | } // namespace shill |
| 504 | |
Wade Guthrie | 89e6cb3 | 2013-03-07 08:03:45 -0800 | [diff] [blame] | 505 | #endif // SHILL_NL80211_MESSAGE_H_ |