blob: d6ed7af856c67bc82b66ea600b71b8ab754ed327 [file] [log] [blame]
Wade Guthrie0d438532012-05-18 14:18:50 -07001// 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 Guthrie89e6cb32013-03-07 08:03:45 -08005#ifndef SHILL_NL80211_MESSAGE_H_
6#define SHILL_NL80211_MESSAGE_H_
Wade Guthrie0d438532012-05-18 14:18:50 -07007
Wade Guthrie0d438532012-05-18 14:18:50 -07008#include <map>
Wade Guthrie0d438532012-05-18 14:18:50 -07009#include <string>
Wade Guthrie8343f7f2012-12-04 13:52:32 -080010#include <vector>
Wade Guthrie0d438532012-05-18 14:18:50 -070011
Wade Guthrie0d438532012-05-18 14:18:50 -070012#include <base/lazy_instance.h>
Wade Guthrie89e6cb32013-03-07 08:03:45 -080013
repo sync1538d442012-12-20 15:24:35 -080014#include "shill/byte_string.h"
Wade Guthrie0ae4b8e2013-04-10 16:49:15 -070015#include "shill/generic_netlink_message.h"
Wade Guthrie16196242012-11-20 15:53:52 -080016
Wade Guthrie0d438532012-05-18 14:18:50 -070017struct nlmsghdr;
18
19namespace shill {
20
Wade Guthrief48a1952013-03-04 17:33:47 -080021// Class for messages received from the mac80211 drivers by way of the
22// cfg80211 kernel module.
23class 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 Stewart2ddf2c62013-04-16 09:47:34 -070033 // Gets the family_id / message_type for all Nl80211 messages.
34 static uint16_t GetMessageType();
35
Wade Guthriebee87c22013-03-06 11:00:46 -080036 // Sets the family_id / message_type for all Nl80211 messages.
37 static void SetMessageType(uint16_t message_type);
38
Wade Guthrief48a1952013-03-04 17:33:47 -080039 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 sync90ee0fa2012-12-18 10:08:08 -080047 // TODO(wdg): This needs to be moved to AttributeMac.
Wade Guthrie0d438532012-05-18 14:18:50 -070048 // 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 Guthrie68da97c2013-02-26 13:09:35 -080051 bool GetMacAttributeString(int id, std::string *value) const;
Wade Guthrie0d438532012-05-18 14:18:50 -070052
repo sync90ee0fa2012-12-18 10:08:08 -080053 // TODO(wdg): This needs to be moved to AttributeScanFrequencies.
Wade Guthrie0d438532012-05-18 14:18:50 -070054 // Helper function to provide a vector of scan frequencies for attributes
55 // that contain them (such as NL80211_ATTR_SCAN_FREQUENCIES).
Wade Guthrie68da97c2013-02-26 13:09:35 -080056 bool GetScanFrequenciesAttribute(int id, std::vector<uint32_t> *value) const;
Wade Guthrie0d438532012-05-18 14:18:50 -070057
repo sync90ee0fa2012-12-18 10:08:08 -080058 // TODO(wdg): This needs to be moved to AttributeScanSSids.
Wade Guthrie0d438532012-05-18 14:18:50 -070059 // Helper function to provide a vector of SSIDs for attributes that contain
60 // them (such as NL80211_ATTR_SCAN_SSIDS).
Wade Guthrie68da97c2013-02-26 13:09:35 -080061 bool GetScanSsidsAttribute(int id, std::vector<std::string> *value) const;
Wade Guthrie0d438532012-05-18 14:18:50 -070062
repo sync90ee0fa2012-12-18 10:08:08 -080063 // TODO(wdg): This needs to be moved to AttributeMac.
Wade Guthrie0d438532012-05-18 14:18:50 -070064 // 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 Guthried4977f22012-08-22 12:37:54 -070068 // 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 Guthrie0d438532012-05-18 14:18:50 -070070 // NL80211_ATTR_STATUS_CODE or NL80211_ATTR_REASON_CODE attribute).
Wade Guthried4977f22012-08-22 12:37:54 -070071 static std::string StringFromReason(uint16_t reason);
Wade Guthrie0d438532012-05-18 14:18:50 -070072 static std::string StringFromStatus(uint16_t status);
73
Wade Guthrie12f113a2013-03-12 17:15:46 -070074 // Message factory for all types of Nl80211 message.
75 static NetlinkMessage *CreateMessage(const nlmsghdr *const_msg);
76
Wade Guthrie0d438532012-05-18 14:18:50 -070077 private:
Wade Guthried4977f22012-08-22 12:37:54 -070078 static std::map<uint16_t, std::string> *reason_code_string_;
79 static std::map<uint16_t, std::string> *status_code_string_;
Wade Guthrief48a1952013-03-04 17:33:47 -080080 static uint16_t nl80211_message_type_;
Wade Guthrie0d438532012-05-18 14:18:50 -070081
repo syncdc085c82012-12-28 08:54:41 -080082 DISALLOW_COPY_AND_ASSIGN(Nl80211Message);
Wade Guthrie0d438532012-05-18 14:18:50 -070083};
84
85class 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 syncd316eb72012-12-10 15:48:47 -080098 explicit Nl80211Frame(const ByteString &init);
Wade Guthried4977f22012-08-22 12:37:54 -070099 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 Guthrie0d438532012-05-18 14:18:50 -0700103
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 Guthried4977f22012-08-22 12:37:54 -0700111 uint16_t reason_;
Wade Guthrie0d438532012-05-18 14:18:50 -0700112 uint16_t status_;
Wade Guthrie8343f7f2012-12-04 13:52:32 -0800113 ByteString frame_;
Wade Guthrie0d438532012-05-18 14:18:50 -0700114
115 DISALLOW_COPY_AND_ASSIGN(Nl80211Frame);
116};
117
118//
repo syncdc085c82012-12-28 08:54:41 -0800119// Specific Nl80211Message types.
Wade Guthrie0d438532012-05-18 14:18:50 -0700120//
121
repo syncdc085c82012-12-28 08:54:41 -0800122class AssociateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700123 public:
124 static const uint8_t kCommand;
125 static const char kCommandString[];
126
repo syncdc085c82012-12-28 08:54:41 -0800127 AssociateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700128
Wade Guthrie0d438532012-05-18 14:18:50 -0700129 private:
130 DISALLOW_COPY_AND_ASSIGN(AssociateMessage);
131};
132
133
repo syncdc085c82012-12-28 08:54:41 -0800134class AuthenticateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700135 public:
136 static const uint8_t kCommand;
137 static const char kCommandString[];
138
repo syncdc085c82012-12-28 08:54:41 -0800139 AuthenticateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700140
Wade Guthrie0d438532012-05-18 14:18:50 -0700141 private:
142 DISALLOW_COPY_AND_ASSIGN(AuthenticateMessage);
143};
144
145
repo syncdc085c82012-12-28 08:54:41 -0800146class CancelRemainOnChannelMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700147 public:
148 static const uint8_t kCommand;
149 static const char kCommandString[];
150
Christopher Wiley764538d2012-11-09 10:58:23 -0800151 CancelRemainOnChannelMessage()
repo syncdc085c82012-12-28 08:54:41 -0800152 : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700153
Wade Guthrie0d438532012-05-18 14:18:50 -0700154 private:
155 DISALLOW_COPY_AND_ASSIGN(CancelRemainOnChannelMessage);
156};
157
158
repo syncdc085c82012-12-28 08:54:41 -0800159class ConnectMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700160 public:
161 static const uint8_t kCommand;
162 static const char kCommandString[];
163
repo syncdc085c82012-12-28 08:54:41 -0800164 ConnectMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700165
Wade Guthrie0d438532012-05-18 14:18:50 -0700166 private:
167 DISALLOW_COPY_AND_ASSIGN(ConnectMessage);
168};
169
170
repo syncdc085c82012-12-28 08:54:41 -0800171class DeauthenticateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700172 public:
173 static const uint8_t kCommand;
174 static const char kCommandString[];
175
repo syncdc085c82012-12-28 08:54:41 -0800176 DeauthenticateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700177
Wade Guthrie0d438532012-05-18 14:18:50 -0700178 private:
179 DISALLOW_COPY_AND_ASSIGN(DeauthenticateMessage);
180};
181
182
repo syncdc085c82012-12-28 08:54:41 -0800183class DeleteStationMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700184 public:
185 static const uint8_t kCommand;
186 static const char kCommandString[];
187
repo syncdc085c82012-12-28 08:54:41 -0800188 DeleteStationMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700189
Wade Guthrie0d438532012-05-18 14:18:50 -0700190 private:
191 DISALLOW_COPY_AND_ASSIGN(DeleteStationMessage);
192};
193
194
repo syncdc085c82012-12-28 08:54:41 -0800195class DisassociateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700196 public:
197 static const uint8_t kCommand;
198 static const char kCommandString[];
199
repo syncdc085c82012-12-28 08:54:41 -0800200 DisassociateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700201
Wade Guthrie0d438532012-05-18 14:18:50 -0700202 private:
203 DISALLOW_COPY_AND_ASSIGN(DisassociateMessage);
204};
205
206
repo syncdc085c82012-12-28 08:54:41 -0800207class DisconnectMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700208 public:
209 static const uint8_t kCommand;
210 static const char kCommandString[];
211
repo syncdc085c82012-12-28 08:54:41 -0800212 DisconnectMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700213
Wade Guthrie0d438532012-05-18 14:18:50 -0700214 private:
215 DISALLOW_COPY_AND_ASSIGN(DisconnectMessage);
216};
217
218
repo syncdc085c82012-12-28 08:54:41 -0800219class FrameTxStatusMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700220 public:
221 static const uint8_t kCommand;
222 static const char kCommandString[];
223
repo syncdc085c82012-12-28 08:54:41 -0800224 FrameTxStatusMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700225
Wade Guthrie0d438532012-05-18 14:18:50 -0700226 private:
227 DISALLOW_COPY_AND_ASSIGN(FrameTxStatusMessage);
228};
229
repo sync0efa9f02012-12-28 13:40:20 -0800230class 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 Guthrie1f355e82013-04-11 15:46:12 -0700241class GetWiphyMessage : public Nl80211Message {
242 public:
243 static const uint8_t kCommand;
244 static const char kCommandString[];
245
Wade Guthrie92d06362013-04-25 15:41:30 -0700246 GetWiphyMessage();
Wade Guthrie1f355e82013-04-11 15:46:12 -0700247
248 private:
249 DISALLOW_COPY_AND_ASSIGN(GetWiphyMessage);
250};
251
Wade Guthrie0d438532012-05-18 14:18:50 -0700252
repo syncdc085c82012-12-28 08:54:41 -0800253class JoinIbssMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700254 public:
255 static const uint8_t kCommand;
256 static const char kCommandString[];
257
repo syncdc085c82012-12-28 08:54:41 -0800258 JoinIbssMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700259
Wade Guthrie0d438532012-05-18 14:18:50 -0700260 private:
261 DISALLOW_COPY_AND_ASSIGN(JoinIbssMessage);
262};
263
264
repo syncdc085c82012-12-28 08:54:41 -0800265class MichaelMicFailureMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700266 public:
267 static const uint8_t kCommand;
268 static const char kCommandString[];
269
repo syncdc085c82012-12-28 08:54:41 -0800270 MichaelMicFailureMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700271
Wade Guthrie0d438532012-05-18 14:18:50 -0700272 private:
273 DISALLOW_COPY_AND_ASSIGN(MichaelMicFailureMessage);
274};
275
276
repo syncdc085c82012-12-28 08:54:41 -0800277class NewScanResultsMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700278 public:
279 static const uint8_t kCommand;
280 static const char kCommandString[];
281
repo syncdc085c82012-12-28 08:54:41 -0800282 NewScanResultsMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700283
Wade Guthrie0d438532012-05-18 14:18:50 -0700284 private:
285 DISALLOW_COPY_AND_ASSIGN(NewScanResultsMessage);
286};
287
288
repo syncdc085c82012-12-28 08:54:41 -0800289class NewStationMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700290 public:
291 static const uint8_t kCommand;
292 static const char kCommandString[];
293
repo syncdc085c82012-12-28 08:54:41 -0800294 NewStationMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700295
Wade Guthrie0d438532012-05-18 14:18:50 -0700296 private:
297 DISALLOW_COPY_AND_ASSIGN(NewStationMessage);
298};
299
300
Wade Guthrie1f355e82013-04-11 15:46:12 -0700301class NewWiphyMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700302 public:
303 static const uint8_t kCommand;
304 static const char kCommandString[];
305
Wade Guthrie1f355e82013-04-11 15:46:12 -0700306 NewWiphyMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700307
Wade Guthrie0d438532012-05-18 14:18:50 -0700308 private:
Wade Guthrie1f355e82013-04-11 15:46:12 -0700309 DISALLOW_COPY_AND_ASSIGN(NewWiphyMessage);
Wade Guthrie0d438532012-05-18 14:18:50 -0700310};
311
312
repo syncdc085c82012-12-28 08:54:41 -0800313class NotifyCqmMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700314 public:
315 static const uint8_t kCommand;
316 static const char kCommandString[];
317
repo syncdc085c82012-12-28 08:54:41 -0800318 NotifyCqmMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700319
Wade Guthrie0d438532012-05-18 14:18:50 -0700320 private:
321 DISALLOW_COPY_AND_ASSIGN(NotifyCqmMessage);
322};
323
324
repo syncdc085c82012-12-28 08:54:41 -0800325class PmksaCandidateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700326 public:
327 static const uint8_t kCommand;
328 static const char kCommandString[];
329
repo syncdc085c82012-12-28 08:54:41 -0800330 PmksaCandidateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700331
Wade Guthrie0d438532012-05-18 14:18:50 -0700332 private:
333 DISALLOW_COPY_AND_ASSIGN(PmksaCandidateMessage);
334};
335
336
repo syncdc085c82012-12-28 08:54:41 -0800337class RegBeaconHintMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700338 public:
339 static const uint8_t kCommand;
340 static const char kCommandString[];
341
repo syncdc085c82012-12-28 08:54:41 -0800342 RegBeaconHintMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700343
Wade Guthrie0d438532012-05-18 14:18:50 -0700344 private:
Wade Guthrie0d438532012-05-18 14:18:50 -0700345 DISALLOW_COPY_AND_ASSIGN(RegBeaconHintMessage);
346};
347
348
repo syncdc085c82012-12-28 08:54:41 -0800349class RegChangeMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700350 public:
351 static const uint8_t kCommand;
352 static const char kCommandString[];
353
repo syncdc085c82012-12-28 08:54:41 -0800354 RegChangeMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700355
Wade Guthrie0d438532012-05-18 14:18:50 -0700356 private:
357 DISALLOW_COPY_AND_ASSIGN(RegChangeMessage);
358};
359
360
repo syncdc085c82012-12-28 08:54:41 -0800361class RemainOnChannelMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700362 public:
363 static const uint8_t kCommand;
364 static const char kCommandString[];
365
repo syncdc085c82012-12-28 08:54:41 -0800366 RemainOnChannelMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700367
Wade Guthrie0d438532012-05-18 14:18:50 -0700368 private:
369 DISALLOW_COPY_AND_ASSIGN(RemainOnChannelMessage);
370};
371
372
repo syncdc085c82012-12-28 08:54:41 -0800373class RoamMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700374 public:
375 static const uint8_t kCommand;
376 static const char kCommandString[];
377
repo syncdc085c82012-12-28 08:54:41 -0800378 RoamMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700379
Wade Guthrie0d438532012-05-18 14:18:50 -0700380 private:
381 DISALLOW_COPY_AND_ASSIGN(RoamMessage);
382};
383
384
repo syncdc085c82012-12-28 08:54:41 -0800385class ScanAbortedMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700386 public:
387 static const uint8_t kCommand;
388 static const char kCommandString[];
389
repo syncdc085c82012-12-28 08:54:41 -0800390 ScanAbortedMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700391
Wade Guthrie0d438532012-05-18 14:18:50 -0700392 private:
393 DISALLOW_COPY_AND_ASSIGN(ScanAbortedMessage);
394};
395
396
Wade Guthrie71872472013-03-05 10:33:38 -0800397class 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 syncdc085c82012-12-28 08:54:41 -0800409class TriggerScanMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700410 public:
411 static const uint8_t kCommand;
412 static const char kCommandString[];
413
Wade Guthrieb9c3feb2013-04-25 16:31:19 -0700414 TriggerScanMessage();
Wade Guthrie0d438532012-05-18 14:18:50 -0700415
Wade Guthrie0d438532012-05-18 14:18:50 -0700416 private:
417 DISALLOW_COPY_AND_ASSIGN(TriggerScanMessage);
418};
419
420
repo syncdc085c82012-12-28 08:54:41 -0800421class UnprotDeauthenticateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700422 public:
423 static const uint8_t kCommand;
424 static const char kCommandString[];
425
Christopher Wiley764538d2012-11-09 10:58:23 -0800426 UnprotDeauthenticateMessage()
repo syncdc085c82012-12-28 08:54:41 -0800427 : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700428
Wade Guthrie0d438532012-05-18 14:18:50 -0700429 private:
430 DISALLOW_COPY_AND_ASSIGN(UnprotDeauthenticateMessage);
431};
432
433
repo syncdc085c82012-12-28 08:54:41 -0800434class UnprotDisassociateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700435 public:
436 static const uint8_t kCommand;
437 static const char kCommandString[];
438
repo syncdc085c82012-12-28 08:54:41 -0800439 UnprotDisassociateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700440
Wade Guthrie0d438532012-05-18 14:18:50 -0700441 private:
442 DISALLOW_COPY_AND_ASSIGN(UnprotDisassociateMessage);
443};
444
Paul Stewart2ddf2c62013-04-16 09:47:34 -0700445
446class GetInterfaceMessage : public Nl80211Message {
447 public:
448 static const uint8_t kCommand;
449 static const char kCommandString[];
450
451 GetInterfaceMessage();
452
453 private:
454 DISALLOW_COPY_AND_ASSIGN(GetInterfaceMessage);
455};
456
457class NewInterfaceMessage : public Nl80211Message {
458 public:
459 static const uint8_t kCommand;
460 static const char kCommandString[];
461
462 NewInterfaceMessage() : Nl80211Message(kCommand, kCommandString) {}
463
464 private:
465 DISALLOW_COPY_AND_ASSIGN(NewInterfaceMessage);
466};
467
repo syncdc085c82012-12-28 08:54:41 -0800468// Nl80211MessageDataCollector - this class is used to collect data to be
Wade Guthrie0d438532012-05-18 14:18:50 -0700469// used for unit tests. It is only invoked in this case.
470
repo syncdc085c82012-12-28 08:54:41 -0800471class Nl80211MessageDataCollector {
Wade Guthrie0d438532012-05-18 14:18:50 -0700472 public:
repo syncdc085c82012-12-28 08:54:41 -0800473 static Nl80211MessageDataCollector *GetInstance();
Wade Guthrie0d438532012-05-18 14:18:50 -0700474
repo syncdc085c82012-12-28 08:54:41 -0800475 void CollectDebugData(const Nl80211Message &message, nlmsghdr *msg);
Wade Guthrie0d438532012-05-18 14:18:50 -0700476
477 protected:
478 friend struct
repo syncdc085c82012-12-28 08:54:41 -0800479 base::DefaultLazyInstanceTraits<Nl80211MessageDataCollector>;
Wade Guthrie0d438532012-05-18 14:18:50 -0700480
repo syncdc085c82012-12-28 08:54:41 -0800481 explicit Nl80211MessageDataCollector();
Wade Guthrie0d438532012-05-18 14:18:50 -0700482
483 private:
484 // In order to limit the output from this class, I keep track of types I
485 // haven't yet printed.
486 std::map<uint8_t, bool> need_to_print;
repo syncdc085c82012-12-28 08:54:41 -0800487
488 DISALLOW_COPY_AND_ASSIGN(Nl80211MessageDataCollector);
Wade Guthrie0d438532012-05-18 14:18:50 -0700489};
490
491} // namespace shill
492
Wade Guthrie89e6cb32013-03-07 08:03:45 -0800493#endif // SHILL_NL80211_MESSAGE_H_