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