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 | |
| 5 | #ifndef SHILL_USER_BOUND_NLMESSAGE_H_ |
| 6 | #define SHILL_USER_BOUND_NLMESSAGE_H_ |
| 7 | |
Wade Guthrie | 8343f7f | 2012-12-04 13:52:32 -0800 | [diff] [blame] | 8 | #include <linux/nl80211.h> |
| 9 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 10 | #include <iomanip> |
| 11 | #include <map> |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 12 | #include <string> |
Wade Guthrie | 8343f7f | 2012-12-04 13:52:32 -0800 | [diff] [blame] | 13 | #include <vector> |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 14 | |
| 15 | #include <base/basictypes.h> |
| 16 | #include <base/bind.h> |
| 17 | #include <base/lazy_instance.h> |
| 18 | #include <gtest/gtest.h> |
| 19 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 20 | #include "shill/attribute_list.h" |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 21 | #include "shill/byte_string.h" |
Wade Guthrie | efe1f0c | 2013-02-26 17:42:01 -0800 | [diff] [blame] | 22 | #include "shill/refptr_types.h" |
Wade Guthrie | 1619624 | 2012-11-20 15:53:52 -0800 | [diff] [blame] | 23 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 24 | struct nlattr; |
| 25 | struct nlmsghdr; |
| 26 | |
| 27 | namespace shill { |
| 28 | |
Wade Guthrie | bdcdaa7 | 2013-03-04 12:47:12 -0800 | [diff] [blame] | 29 | class Config80211; |
| 30 | |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 31 | // Netlink messages are sent over netlink sockets to talk between user-space |
| 32 | // programs (like shill) and kernel modules (like the cfg80211 module). Each |
| 33 | // kernel module that talks netlink potentially adds its own family header to |
| 34 | // the nlmsghdr (the top-level netlink message header) and, potentially, uses a |
| 35 | // different payload format. The NetlinkMessage class represents that which |
| 36 | // is common between the different types of netlink message. |
| 37 | // |
| 38 | // The common portions of Netlink Messages start with a |nlmsghdr|. Those |
| 39 | // messages look something like the following (the functions, macros, and |
| 40 | // datatypes described are provided by libnl -- see also |
| 41 | // http://www.infradead.org/~tgr/libnl/doc/core.html): |
| 42 | // |
| 43 | // |<--------------nlmsg_total_size()----------->| |
| 44 | // | |<------nlmsg_datalen()-------------->| |
| 45 | // | | | |
| 46 | // -----+-----+-+-----------------------------------+-+---- |
| 47 | // ... | | | netlink payload | | |
| 48 | // | | +------------+-+--------------------+ | |
| 49 | // | nl | | | | | | nl |
| 50 | // | msg |p| (optional) |p| |p| msg ... |
| 51 | // | hdr |a| family |a| family payload |a| hdr |
| 52 | // | |d| header |d| |d| |
| 53 | // | | | | | | | |
| 54 | // -----+-----+-+------------+-+--------------------+-+---- |
| 55 | // ^ |
| 56 | // | |
| 57 | // +-- nlmsg_data() |
| 58 | // |
| 59 | // All NetlinkMessages sent to the kernel need a valid message type (which is |
| 60 | // found in the nlmsghdr structure) and all NetlinkMessages received from the |
| 61 | // kernel have a valid message type. Some message types (NLMSG_NOOP, |
| 62 | // NLMSG_ERROR, and GENL_ID_CTRL, for example) are allocated statically; for |
| 63 | // those, the |message_type_| is assigned directly. |
| 64 | // |
| 65 | // Other message types ("nl80211", for example), are assigned by the kernel |
| 66 | // dynamically. To get the message type, pass a closure to assign the |
| 67 | // message_type along with the sting to Config80211::AddFamilyByString: |
| 68 | // |
| 69 | // config80211_->AddFamilyByString(Nl80211Message::kMessageType, |
| 70 | // Bind(&Nl80211Message::SetFamilyId)); |
| 71 | // |
| 72 | // Do all of this before you start to create NetlinkMessages so that |
| 73 | // NetlinkMessage can be instantiated with a valid |message_type_|. |
| 74 | |
| 75 | class NetlinkMessage { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 76 | public: |
Wade Guthrie | bdcdaa7 | 2013-03-04 12:47:12 -0800 | [diff] [blame] | 77 | static const uint32_t kBroadcastSequenceNumber; |
| 78 | static const uint16_t kIllegalMessageType; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 79 | |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 80 | explicit NetlinkMessage(uint16_t message_type) : |
| 81 | flags_(0), message_type_(message_type), |
| 82 | sequence_number_(kBroadcastSequenceNumber) {} |
| 83 | virtual ~NetlinkMessage() {} |
| 84 | |
| 85 | // Returns a string of bytes representing the message (with it headers) and |
| 86 | // any necessary padding. These bytes are appropriately formatted to be |
| 87 | // written to a netlink socket. |
| 88 | virtual ByteString Encode(uint32_t sequence_number, uint16_t nlmsg_type) = 0; |
| 89 | |
| 90 | // Initializes the |NetlinkMessage| from a complete and legal message |
| 91 | // (potentially received from the kernel via a netlink socket). |
| 92 | virtual bool InitFromNlmsg(const nlmsghdr *msg); |
| 93 | |
| 94 | uint16_t message_type() const { return message_type_; } |
| 95 | void AddFlag(uint16_t new_flag) { flags_ |= new_flag; } |
| 96 | uint16_t flags() const { return flags_; } |
| 97 | uint32_t sequence_number() const { return sequence_number_; } |
| 98 | virtual void Print(int log_level) const = 0; |
| 99 | |
| 100 | // Logs the message's raw bytes (with minimal interpretation). |
| 101 | static void PrintBytes(int log_level, const unsigned char *buf, |
| 102 | size_t num_bytes); |
| 103 | |
| 104 | protected: |
| 105 | friend class Config80211Test; |
| 106 | FRIEND_TEST(Config80211Test, NL80211_CMD_NOTIFY_CQM); |
| 107 | |
| 108 | // Returns a string of bytes representing an |nlmsghdr|, filled-in, and its |
| 109 | // padding. |
| 110 | virtual ByteString EncodeHeader(uint32_t sequence_number, |
| 111 | uint16_t nlmsg_type); |
| 112 | // Reads the |nlmsghdr| and removes it from |input|. |
| 113 | virtual bool InitAndStripHeader(ByteString *input); |
| 114 | |
| 115 | uint16_t flags_; |
| 116 | uint16_t message_type_; |
| 117 | uint32_t sequence_number_; |
| 118 | |
| 119 | private: |
| 120 | DISALLOW_COPY_AND_ASSIGN(NetlinkMessage); |
| 121 | }; |
| 122 | |
Wade Guthrie | 7187247 | 2013-03-05 10:33:38 -0800 | [diff] [blame^] | 123 | |
| 124 | // The Error and Ack messages are received from the kernel and are combined, |
| 125 | // here, because they look so much alike (the only difference is that the |
| 126 | // error code is 0 for the Ack messages). Error messages are received from |
| 127 | // the kernel in response to a sent message when there's a problem (such as |
| 128 | // a malformed message or a busy kernel module). Ack messages are received |
| 129 | // from the kernel when a sent message has the NLM_F_ACK flag set, indicating |
| 130 | // that an Ack is requested. |
| 131 | class ErrorAckMessage : public NetlinkMessage { |
| 132 | public: |
| 133 | static const uint16_t kMessageType; |
| 134 | |
| 135 | ErrorAckMessage() : NetlinkMessage(kMessageType), error_(0) {} |
| 136 | virtual bool InitFromNlmsg(const nlmsghdr *const_msg); |
| 137 | virtual ByteString Encode(uint32_t sequence_number, uint16_t nlmsg_type); |
| 138 | virtual void Print(int log_level) const; |
| 139 | std::string ToString() const; |
| 140 | uint32_t error() const { return -error_; } |
| 141 | |
| 142 | private: |
| 143 | uint32_t error_; |
| 144 | |
| 145 | DISALLOW_COPY_AND_ASSIGN(ErrorAckMessage); |
| 146 | }; |
| 147 | |
| 148 | |
| 149 | class NoopMessage : public NetlinkMessage { |
| 150 | public: |
| 151 | static const uint16_t kMessageType; |
| 152 | |
| 153 | NoopMessage() : NetlinkMessage(kMessageType) {} |
| 154 | virtual ByteString Encode(uint32_t sequence_number, uint16_t nlmsg_type); |
| 155 | virtual void Print(int log_level) const; |
| 156 | std::string ToString() const { return "<NOOP>"; } |
| 157 | |
| 158 | private: |
| 159 | DISALLOW_COPY_AND_ASSIGN(NoopMessage); |
| 160 | }; |
| 161 | |
| 162 | |
| 163 | class DoneMessage : public NetlinkMessage { |
| 164 | public: |
| 165 | static const uint16_t kMessageType; |
| 166 | |
| 167 | DoneMessage() : NetlinkMessage(kMessageType) {} |
| 168 | virtual ByteString Encode(uint32_t sequence_number, uint16_t nlmsg_type); |
| 169 | virtual void Print(int log_level) const; |
| 170 | std::string ToString() const { return "<DONE with multipart message>"; } |
| 171 | |
| 172 | private: |
| 173 | DISALLOW_COPY_AND_ASSIGN(DoneMessage); |
| 174 | }; |
| 175 | |
| 176 | |
| 177 | class OverrunMessage : public NetlinkMessage { |
| 178 | public: |
| 179 | static const uint16_t kMessageType; |
| 180 | |
| 181 | OverrunMessage() : NetlinkMessage(kMessageType) {} |
| 182 | virtual ByteString Encode(uint32_t sequence_number, uint16_t nlmsg_type); |
| 183 | virtual void Print(int log_level) const; |
| 184 | std::string ToString() const { return "<OVERRUN - data lost>"; } |
| 185 | |
| 186 | private: |
| 187 | DISALLOW_COPY_AND_ASSIGN(OverrunMessage); |
| 188 | }; |
| 189 | |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 190 | // Objects of the |GenericNetlinkMessage| type represent messages that contain |
| 191 | // a |genlmsghdr| after a |nlmsghdr|. These messages seem to all contain a |
| 192 | // payload that consists of a list of structured attributes (it's possible that |
| 193 | // some messages might have a genlmsghdr and a different kind of payload but I |
| 194 | // haven't seen one, yet). The genlmsghdr contains a command id that, when |
| 195 | // combined with the family_id (from the nlmsghdr), describes the ultimate use |
| 196 | // for the netlink message. |
| 197 | // |
| 198 | // An attribute contains a header and a chunk of data. The header contains an |
| 199 | // id which is an enumerated value that describes the use of the attribute's |
| 200 | // data (the datatype of the attribute's data is implied by the attribute id) |
| 201 | // and the length of the header+data in bytes. The attribute id is, |
| 202 | // confusingly, called the type (or nla_type -- this is _not_ the data type of |
| 203 | // the attribute). Each family defines the meaning of the nla_types in the |
| 204 | // context of messages in that family (for example, the nla_type with the |
| 205 | // value 3 will always mean the same thing for attributes in the same family). |
| 206 | // EXCEPTION: Some attributes are nested (that is, they contain a list of other |
| 207 | // attributes rather than a single value). Each nested attribute defines the |
| 208 | // meaning of the nla_types in the context of attributes that are nested under |
| 209 | // this attribute (for example, the nla_type with the value 3 will have a |
| 210 | // different meaning when nested under another attribute -- that meaning is |
| 211 | // defined by the attribute under which it is nested). Fun. |
| 212 | // |
| 213 | // The GenericNetlink messages look like this: |
| 214 | // |
| 215 | // -----+-----+-+-------------------------------------------------+-+-- |
| 216 | // ... | | | message payload | | |
| 217 | // | | +------+-+----------------------------------------+ | |
| 218 | // | nl | | | | attributes | | |
| 219 | // | msg |p| genl |p+-----------+-+---------+-+--------+-----+p| ... |
| 220 | // | hdr |a| msg |a| struct |p| attrib |p| struct | ... |a| |
| 221 | // | |d| hdr |d| nlattr |a| payload |a| nlattr | |d| |
| 222 | // | | | | | |d| |d| | | | |
| 223 | // -----+-----+-+------+-+-----------+-+---------+-+--------+-----+-+-- |
| 224 | // | ^ | | |
| 225 | // |<-NLA_HDRLEN->| | | |
| 226 | // | +---nla_data() |
| 227 | // |<----nla_attr_size---->| | |
| 228 | // |<-----nla_total_size---->| |
| 229 | |
| 230 | class GenericNetlinkMessage : public NetlinkMessage { |
| 231 | public: |
| 232 | GenericNetlinkMessage(uint16_t my_message_type, uint8 command, |
| 233 | const char *command_string) |
| 234 | : NetlinkMessage(my_message_type), |
| 235 | attributes_(new AttributeList), |
Wade Guthrie | bdcdaa7 | 2013-03-04 12:47:12 -0800 | [diff] [blame] | 236 | command_(command), |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 237 | command_string_(command_string) {} |
| 238 | virtual ~GenericNetlinkMessage() {} |
| 239 | |
| 240 | virtual ByteString Encode(uint32_t sequence_number, uint16_t nlmsg_type); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 241 | |
Wade Guthrie | bdcdaa7 | 2013-03-04 12:47:12 -0800 | [diff] [blame] | 242 | uint8 command() const { return command_; } |
| 243 | const char *command_string() const { return command_string_; } |
| 244 | |
Wade Guthrie | efe1f0c | 2013-02-26 17:42:01 -0800 | [diff] [blame] | 245 | AttributeListConstRefPtr const_attributes() const { return attributes_; } |
| 246 | AttributeListRefPtr attributes() { return attributes_; } |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 247 | |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 248 | virtual void Print(int log_level) const; |
| 249 | |
| 250 | protected: |
| 251 | // Returns a string of bytes representing _both_ an |nlmsghdr| and a |
| 252 | // |genlmsghdr|, filled-in, and its padding. |
| 253 | virtual ByteString EncodeHeader(uint32_t sequence_number, |
| 254 | uint16_t nlmsg_type); |
| 255 | // Reads the |nlmsghdr| and |genlmsghdr| headers and removes them from |
| 256 | // |input|. |
| 257 | virtual bool InitAndStripHeader(ByteString *input); |
| 258 | |
| 259 | AttributeListRefPtr attributes_; |
| 260 | const uint8 command_; |
| 261 | const char *command_string_; |
| 262 | |
| 263 | private: |
| 264 | DISALLOW_COPY_AND_ASSIGN(GenericNetlinkMessage); |
| 265 | }; |
| 266 | |
Wade Guthrie | 7187247 | 2013-03-05 10:33:38 -0800 | [diff] [blame^] | 267 | // Control Messages |
| 268 | |
| 269 | class ControlNetlinkMessage : public GenericNetlinkMessage { |
| 270 | public: |
| 271 | static const uint16_t kMessageType; |
| 272 | ControlNetlinkMessage(uint8 command, const char *command_string) |
| 273 | : GenericNetlinkMessage(kMessageType, command, command_string) {} |
| 274 | |
| 275 | virtual bool InitFromNlmsg(const nlmsghdr *msg); |
| 276 | }; |
| 277 | |
| 278 | class NewFamilyMessage : public ControlNetlinkMessage { |
| 279 | public: |
| 280 | static const uint8_t kCommand; |
| 281 | static const char kCommandString[]; |
| 282 | |
| 283 | NewFamilyMessage() : ControlNetlinkMessage(kCommand, kCommandString) {} |
| 284 | |
| 285 | private: |
| 286 | DISALLOW_COPY_AND_ASSIGN(NewFamilyMessage); |
| 287 | }; |
| 288 | |
| 289 | class GetFamilyMessage : public ControlNetlinkMessage { |
| 290 | public: |
| 291 | static const uint8_t kCommand; |
| 292 | static const char kCommandString[]; |
| 293 | |
| 294 | GetFamilyMessage() : ControlNetlinkMessage(kCommand, kCommandString) {} |
| 295 | |
| 296 | private: |
| 297 | DISALLOW_COPY_AND_ASSIGN(GetFamilyMessage); |
| 298 | }; |
| 299 | |
| 300 | |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 301 | // Class for messages received from the mac80211 drivers by way of the |
| 302 | // cfg80211 kernel module. |
| 303 | class Nl80211Message : public GenericNetlinkMessage { |
| 304 | public: |
| 305 | static const char kMessageTypeString[]; |
| 306 | static const unsigned int kEthernetAddressBytes; |
| 307 | static const char kBogusMacAddress[]; |
| 308 | |
| 309 | Nl80211Message(uint8 command, const char *command_string) |
| 310 | : GenericNetlinkMessage(nl80211_message_type_, command, command_string) {} |
| 311 | virtual ~Nl80211Message() {} |
| 312 | |
| 313 | virtual bool InitFromNlmsg(const nlmsghdr *msg); |
| 314 | |
| 315 | uint8 command() const { return command_; } |
| 316 | const char *command_string() const { return command_string_; } |
| 317 | uint16_t message_type() const { return message_type_; } |
| 318 | uint32_t sequence_number() const { return sequence_number_; } |
| 319 | void set_sequence_number(uint32_t seq) { sequence_number_ = seq; } |
| 320 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 321 | // TODO(wdg): This needs to be moved to AttributeMac. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 322 | // Helper function to provide a string for a MAC address. If no attribute |
| 323 | // is found, this method returns 'false'. On any error with a non-NULL |
| 324 | // |value|, this method sets |value| to a bogus MAC address. |
Wade Guthrie | 68da97c | 2013-02-26 13:09:35 -0800 | [diff] [blame] | 325 | bool GetMacAttributeString(int id, std::string *value) const; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 326 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 327 | // TODO(wdg): This needs to be moved to AttributeScanFrequencies. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 328 | // Helper function to provide a vector of scan frequencies for attributes |
| 329 | // that contain them (such as NL80211_ATTR_SCAN_FREQUENCIES). |
Wade Guthrie | 68da97c | 2013-02-26 13:09:35 -0800 | [diff] [blame] | 330 | bool GetScanFrequenciesAttribute(int id, std::vector<uint32_t> *value) const; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 331 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 332 | // TODO(wdg): This needs to be moved to AttributeScanSSids. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 333 | // Helper function to provide a vector of SSIDs for attributes that contain |
| 334 | // them (such as NL80211_ATTR_SCAN_SSIDS). |
Wade Guthrie | 68da97c | 2013-02-26 13:09:35 -0800 | [diff] [blame] | 335 | bool GetScanSsidsAttribute(int id, std::vector<std::string> *value) const; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 336 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 337 | // TODO(wdg): This needs to be moved to AttributeMac. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 338 | // Stringizes the MAC address found in 'arg'. If there are problems (such |
| 339 | // as a NULL |arg|), |value| is set to a bogus MAC address. |
| 340 | static std::string StringFromMacAddress(const uint8_t *arg); |
| 341 | |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 342 | // Returns a string representing the passed-in |status| or |reason|, the |
| 343 | // value of which has been acquired from libnl (for example, from the |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 344 | // NL80211_ATTR_STATUS_CODE or NL80211_ATTR_REASON_CODE attribute). |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 345 | static std::string StringFromReason(uint16_t reason); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 346 | static std::string StringFromStatus(uint16_t status); |
| 347 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 348 | private: |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 349 | static std::map<uint16_t, std::string> *reason_code_string_; |
| 350 | static std::map<uint16_t, std::string> *status_code_string_; |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 351 | static uint16_t nl80211_message_type_; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 352 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 353 | DISALLOW_COPY_AND_ASSIGN(Nl80211Message); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 354 | }; |
| 355 | |
| 356 | class Nl80211Frame { |
| 357 | public: |
| 358 | enum Type { |
| 359 | kAssocResponseFrameType = 0x10, |
| 360 | kReassocResponseFrameType = 0x30, |
| 361 | kAssocRequestFrameType = 0x00, |
| 362 | kReassocRequestFrameType = 0x20, |
| 363 | kAuthFrameType = 0xb0, |
| 364 | kDisassocFrameType = 0xa0, |
| 365 | kDeauthFrameType = 0xc0, |
| 366 | kIllegalFrameType = 0xff |
| 367 | }; |
| 368 | |
repo sync | d316eb7 | 2012-12-10 15:48:47 -0800 | [diff] [blame] | 369 | explicit Nl80211Frame(const ByteString &init); |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 370 | bool ToString(std::string *output) const; |
| 371 | bool IsEqual(const Nl80211Frame &other) const; |
| 372 | uint16_t reason() const { return reason_; } |
| 373 | uint16_t status() const { return status_; } |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 374 | |
| 375 | private: |
| 376 | static const uint8_t kMinimumFrameByteCount; |
| 377 | static const uint8_t kFrameTypeMask; |
| 378 | |
| 379 | std::string mac_from_; |
| 380 | std::string mac_to_; |
| 381 | uint8_t frame_type_; |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 382 | uint16_t reason_; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 383 | uint16_t status_; |
Wade Guthrie | 8343f7f | 2012-12-04 13:52:32 -0800 | [diff] [blame] | 384 | ByteString frame_; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 385 | |
| 386 | DISALLOW_COPY_AND_ASSIGN(Nl80211Frame); |
| 387 | }; |
| 388 | |
| 389 | // |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 390 | // Specific Nl80211Message types. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 391 | // |
| 392 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 393 | class AssociateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 394 | public: |
| 395 | static const uint8_t kCommand; |
| 396 | static const char kCommandString[]; |
| 397 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 398 | AssociateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 399 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 400 | private: |
| 401 | DISALLOW_COPY_AND_ASSIGN(AssociateMessage); |
| 402 | }; |
| 403 | |
| 404 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 405 | class AuthenticateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 406 | public: |
| 407 | static const uint8_t kCommand; |
| 408 | static const char kCommandString[]; |
| 409 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 410 | AuthenticateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 411 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 412 | private: |
| 413 | DISALLOW_COPY_AND_ASSIGN(AuthenticateMessage); |
| 414 | }; |
| 415 | |
| 416 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 417 | class CancelRemainOnChannelMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 418 | public: |
| 419 | static const uint8_t kCommand; |
| 420 | static const char kCommandString[]; |
| 421 | |
Christopher Wiley | 764538d | 2012-11-09 10:58:23 -0800 | [diff] [blame] | 422 | CancelRemainOnChannelMessage() |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 423 | : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 424 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 425 | private: |
| 426 | DISALLOW_COPY_AND_ASSIGN(CancelRemainOnChannelMessage); |
| 427 | }; |
| 428 | |
| 429 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 430 | class ConnectMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 431 | public: |
| 432 | static const uint8_t kCommand; |
| 433 | static const char kCommandString[]; |
| 434 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 435 | ConnectMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 436 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 437 | private: |
| 438 | DISALLOW_COPY_AND_ASSIGN(ConnectMessage); |
| 439 | }; |
| 440 | |
| 441 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 442 | class DeauthenticateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 443 | public: |
| 444 | static const uint8_t kCommand; |
| 445 | static const char kCommandString[]; |
| 446 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 447 | DeauthenticateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 448 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 449 | private: |
| 450 | DISALLOW_COPY_AND_ASSIGN(DeauthenticateMessage); |
| 451 | }; |
| 452 | |
| 453 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 454 | class DeleteStationMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 455 | public: |
| 456 | static const uint8_t kCommand; |
| 457 | static const char kCommandString[]; |
| 458 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 459 | DeleteStationMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 460 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 461 | private: |
| 462 | DISALLOW_COPY_AND_ASSIGN(DeleteStationMessage); |
| 463 | }; |
| 464 | |
| 465 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 466 | class DisassociateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 467 | public: |
| 468 | static const uint8_t kCommand; |
| 469 | static const char kCommandString[]; |
| 470 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 471 | DisassociateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 472 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 473 | private: |
| 474 | DISALLOW_COPY_AND_ASSIGN(DisassociateMessage); |
| 475 | }; |
| 476 | |
| 477 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 478 | class DisconnectMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 479 | public: |
| 480 | static const uint8_t kCommand; |
| 481 | static const char kCommandString[]; |
| 482 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 483 | DisconnectMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 484 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 485 | private: |
| 486 | DISALLOW_COPY_AND_ASSIGN(DisconnectMessage); |
| 487 | }; |
| 488 | |
| 489 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 490 | class FrameTxStatusMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 491 | public: |
| 492 | static const uint8_t kCommand; |
| 493 | static const char kCommandString[]; |
| 494 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 495 | FrameTxStatusMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 496 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 497 | private: |
| 498 | DISALLOW_COPY_AND_ASSIGN(FrameTxStatusMessage); |
| 499 | }; |
| 500 | |
repo sync | 0efa9f0 | 2012-12-28 13:40:20 -0800 | [diff] [blame] | 501 | class GetRegMessage : public Nl80211Message { |
| 502 | public: |
| 503 | static const uint8_t kCommand; |
| 504 | static const char kCommandString[]; |
| 505 | |
| 506 | GetRegMessage() : Nl80211Message(kCommand, kCommandString) {} |
| 507 | |
| 508 | private: |
| 509 | DISALLOW_COPY_AND_ASSIGN(GetRegMessage); |
| 510 | }; |
| 511 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 512 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 513 | class JoinIbssMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 514 | public: |
| 515 | static const uint8_t kCommand; |
| 516 | static const char kCommandString[]; |
| 517 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 518 | JoinIbssMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 519 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 520 | private: |
| 521 | DISALLOW_COPY_AND_ASSIGN(JoinIbssMessage); |
| 522 | }; |
| 523 | |
| 524 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 525 | class MichaelMicFailureMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 526 | public: |
| 527 | static const uint8_t kCommand; |
| 528 | static const char kCommandString[]; |
| 529 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 530 | MichaelMicFailureMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 531 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 532 | private: |
| 533 | DISALLOW_COPY_AND_ASSIGN(MichaelMicFailureMessage); |
| 534 | }; |
| 535 | |
| 536 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 537 | class NewScanResultsMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 538 | public: |
| 539 | static const uint8_t kCommand; |
| 540 | static const char kCommandString[]; |
| 541 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 542 | NewScanResultsMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 543 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 544 | private: |
| 545 | DISALLOW_COPY_AND_ASSIGN(NewScanResultsMessage); |
| 546 | }; |
| 547 | |
| 548 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 549 | class NewStationMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 550 | public: |
| 551 | static const uint8_t kCommand; |
| 552 | static const char kCommandString[]; |
| 553 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 554 | NewStationMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 555 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 556 | private: |
| 557 | DISALLOW_COPY_AND_ASSIGN(NewStationMessage); |
| 558 | }; |
| 559 | |
| 560 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 561 | class NewWifiMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 562 | public: |
| 563 | static const uint8_t kCommand; |
| 564 | static const char kCommandString[]; |
| 565 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 566 | NewWifiMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 567 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 568 | private: |
| 569 | DISALLOW_COPY_AND_ASSIGN(NewWifiMessage); |
| 570 | }; |
| 571 | |
| 572 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 573 | class NotifyCqmMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 574 | public: |
| 575 | static const uint8_t kCommand; |
| 576 | static const char kCommandString[]; |
| 577 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 578 | NotifyCqmMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 579 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 580 | private: |
| 581 | DISALLOW_COPY_AND_ASSIGN(NotifyCqmMessage); |
| 582 | }; |
| 583 | |
| 584 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 585 | class PmksaCandidateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 586 | public: |
| 587 | static const uint8_t kCommand; |
| 588 | static const char kCommandString[]; |
| 589 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 590 | PmksaCandidateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 591 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 592 | private: |
| 593 | DISALLOW_COPY_AND_ASSIGN(PmksaCandidateMessage); |
| 594 | }; |
| 595 | |
| 596 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 597 | class RegBeaconHintMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 598 | public: |
| 599 | static const uint8_t kCommand; |
| 600 | static const char kCommandString[]; |
| 601 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 602 | RegBeaconHintMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 603 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 604 | private: |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 605 | DISALLOW_COPY_AND_ASSIGN(RegBeaconHintMessage); |
| 606 | }; |
| 607 | |
| 608 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 609 | class RegChangeMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 610 | public: |
| 611 | static const uint8_t kCommand; |
| 612 | static const char kCommandString[]; |
| 613 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 614 | RegChangeMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 615 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 616 | private: |
| 617 | DISALLOW_COPY_AND_ASSIGN(RegChangeMessage); |
| 618 | }; |
| 619 | |
| 620 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 621 | class RemainOnChannelMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 622 | public: |
| 623 | static const uint8_t kCommand; |
| 624 | static const char kCommandString[]; |
| 625 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 626 | RemainOnChannelMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 627 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 628 | private: |
| 629 | DISALLOW_COPY_AND_ASSIGN(RemainOnChannelMessage); |
| 630 | }; |
| 631 | |
| 632 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 633 | class RoamMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 634 | public: |
| 635 | static const uint8_t kCommand; |
| 636 | static const char kCommandString[]; |
| 637 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 638 | RoamMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 639 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 640 | private: |
| 641 | DISALLOW_COPY_AND_ASSIGN(RoamMessage); |
| 642 | }; |
| 643 | |
| 644 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 645 | class ScanAbortedMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 646 | public: |
| 647 | static const uint8_t kCommand; |
| 648 | static const char kCommandString[]; |
| 649 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 650 | ScanAbortedMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 651 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 652 | private: |
| 653 | DISALLOW_COPY_AND_ASSIGN(ScanAbortedMessage); |
| 654 | }; |
| 655 | |
| 656 | |
Wade Guthrie | 7187247 | 2013-03-05 10:33:38 -0800 | [diff] [blame^] | 657 | class GetScanMessage : public Nl80211Message { |
| 658 | public: |
| 659 | static const uint8_t kCommand; |
| 660 | static const char kCommandString[]; |
| 661 | |
| 662 | GetScanMessage() : Nl80211Message(kCommand, kCommandString) {} |
| 663 | |
| 664 | private: |
| 665 | DISALLOW_COPY_AND_ASSIGN(GetScanMessage); |
| 666 | }; |
| 667 | |
| 668 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 669 | class TriggerScanMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 670 | public: |
| 671 | static const uint8_t kCommand; |
| 672 | static const char kCommandString[]; |
| 673 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 674 | TriggerScanMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 675 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 676 | private: |
| 677 | DISALLOW_COPY_AND_ASSIGN(TriggerScanMessage); |
| 678 | }; |
| 679 | |
| 680 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 681 | class UnknownMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 682 | public: |
Christopher Wiley | 764538d | 2012-11-09 10:58:23 -0800 | [diff] [blame] | 683 | explicit UnknownMessage(uint8_t command) |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 684 | : Nl80211Message(command, kCommandString), |
Christopher Wiley | 764538d | 2012-11-09 10:58:23 -0800 | [diff] [blame] | 685 | command_(command) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 686 | |
| 687 | static const uint8_t kCommand; |
| 688 | static const char kCommandString[]; |
| 689 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 690 | private: |
| 691 | uint8_t command_; |
| 692 | |
| 693 | DISALLOW_COPY_AND_ASSIGN(UnknownMessage); |
| 694 | }; |
| 695 | |
| 696 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 697 | class UnprotDeauthenticateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 698 | public: |
| 699 | static const uint8_t kCommand; |
| 700 | static const char kCommandString[]; |
| 701 | |
Christopher Wiley | 764538d | 2012-11-09 10:58:23 -0800 | [diff] [blame] | 702 | UnprotDeauthenticateMessage() |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 703 | : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 704 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 705 | private: |
| 706 | DISALLOW_COPY_AND_ASSIGN(UnprotDeauthenticateMessage); |
| 707 | }; |
| 708 | |
| 709 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 710 | class UnprotDisassociateMessage : public Nl80211Message { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 711 | public: |
| 712 | static const uint8_t kCommand; |
| 713 | static const char kCommandString[]; |
| 714 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 715 | UnprotDisassociateMessage() : Nl80211Message(kCommand, kCommandString) {} |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 716 | |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 717 | private: |
| 718 | DISALLOW_COPY_AND_ASSIGN(UnprotDisassociateMessage); |
| 719 | }; |
| 720 | |
| 721 | |
| 722 | // |
| 723 | // Factory class. |
| 724 | // |
| 725 | |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 726 | class NetlinkMessageFactory { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 727 | public: |
| 728 | // Ownership of the message is passed to the caller and, as such, he should |
| 729 | // delete it. |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 730 | static NetlinkMessage *CreateMessage(nlmsghdr *msg); |
| 731 | // TODO(wdg): Need a way for a class to register a callback and a message |
| 732 | // type. That way, CreateMessage can call the appropriate factory based on |
| 733 | // the incoming message type. |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 734 | |
| 735 | private: |
Wade Guthrie | f48a195 | 2013-03-04 17:33:47 -0800 | [diff] [blame] | 736 | DISALLOW_COPY_AND_ASSIGN(NetlinkMessageFactory); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 737 | }; |
| 738 | |
| 739 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 740 | // Nl80211MessageDataCollector - this class is used to collect data to be |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 741 | // used for unit tests. It is only invoked in this case. |
| 742 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 743 | class Nl80211MessageDataCollector { |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 744 | public: |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 745 | static Nl80211MessageDataCollector *GetInstance(); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 746 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 747 | void CollectDebugData(const Nl80211Message &message, nlmsghdr *msg); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 748 | |
| 749 | protected: |
| 750 | friend struct |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 751 | base::DefaultLazyInstanceTraits<Nl80211MessageDataCollector>; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 752 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 753 | explicit Nl80211MessageDataCollector(); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 754 | |
| 755 | private: |
| 756 | // In order to limit the output from this class, I keep track of types I |
| 757 | // haven't yet printed. |
| 758 | std::map<uint8_t, bool> need_to_print; |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 759 | |
| 760 | DISALLOW_COPY_AND_ASSIGN(Nl80211MessageDataCollector); |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 761 | }; |
| 762 | |
| 763 | } // namespace shill |
| 764 | |
| 765 | #endif // SHILL_USER_BOUND_NLMESSAGE_H_ |