blob: 2ba050be7ed2d122dade0cf20d44d1dee9027f56 [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[];
Wade Guthrief48a1952013-03-04 17:33:47 -080026
27 Nl80211Message(uint8 command, const char *command_string)
28 : GenericNetlinkMessage(nl80211_message_type_, command, command_string) {}
29 virtual ~Nl80211Message() {}
30
Paul Stewart2ddf2c62013-04-16 09:47:34 -070031 // Gets the family_id / message_type for all Nl80211 messages.
32 static uint16_t GetMessageType();
33
Wade Guthriebee87c22013-03-06 11:00:46 -080034 // Sets the family_id / message_type for all Nl80211 messages.
35 static void SetMessageType(uint16_t message_type);
36
Wade Guthrief48a1952013-03-04 17:33:47 -080037 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 Guthried4977f22012-08-22 12:37:54 -070045 // 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 Guthrie0d438532012-05-18 14:18:50 -070047 // NL80211_ATTR_STATUS_CODE or NL80211_ATTR_REASON_CODE attribute).
Wade Guthried4977f22012-08-22 12:37:54 -070048 static std::string StringFromReason(uint16_t reason);
Wade Guthrie0d438532012-05-18 14:18:50 -070049 static std::string StringFromStatus(uint16_t status);
50
Wade Guthrie12f113a2013-03-12 17:15:46 -070051 // Message factory for all types of Nl80211 message.
52 static NetlinkMessage *CreateMessage(const nlmsghdr *const_msg);
53
Wade Guthrie0d438532012-05-18 14:18:50 -070054 private:
Wade Guthried4977f22012-08-22 12:37:54 -070055 static std::map<uint16_t, std::string> *reason_code_string_;
56 static std::map<uint16_t, std::string> *status_code_string_;
Wade Guthrief48a1952013-03-04 17:33:47 -080057 static uint16_t nl80211_message_type_;
Wade Guthrie0d438532012-05-18 14:18:50 -070058
repo syncdc085c82012-12-28 08:54:41 -080059 DISALLOW_COPY_AND_ASSIGN(Nl80211Message);
Wade Guthrie0d438532012-05-18 14:18:50 -070060};
61
62class 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 syncd316eb72012-12-10 15:48:47 -080075 explicit Nl80211Frame(const ByteString &init);
Wade Guthried4977f22012-08-22 12:37:54 -070076 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 Guthrie0d438532012-05-18 14:18:50 -070080
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 Guthried4977f22012-08-22 12:37:54 -070088 uint16_t reason_;
Wade Guthrie0d438532012-05-18 14:18:50 -070089 uint16_t status_;
Wade Guthrie8343f7f2012-12-04 13:52:32 -080090 ByteString frame_;
Wade Guthrie0d438532012-05-18 14:18:50 -070091
92 DISALLOW_COPY_AND_ASSIGN(Nl80211Frame);
93};
94
95//
repo syncdc085c82012-12-28 08:54:41 -080096// Specific Nl80211Message types.
Wade Guthrie0d438532012-05-18 14:18:50 -070097//
98
repo syncdc085c82012-12-28 08:54:41 -080099class AssociateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700100 public:
101 static const uint8_t kCommand;
102 static const char kCommandString[];
103
repo syncdc085c82012-12-28 08:54:41 -0800104 AssociateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700105
Wade Guthrie0d438532012-05-18 14:18:50 -0700106 private:
107 DISALLOW_COPY_AND_ASSIGN(AssociateMessage);
108};
109
110
repo syncdc085c82012-12-28 08:54:41 -0800111class AuthenticateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700112 public:
113 static const uint8_t kCommand;
114 static const char kCommandString[];
115
repo syncdc085c82012-12-28 08:54:41 -0800116 AuthenticateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700117
Wade Guthrie0d438532012-05-18 14:18:50 -0700118 private:
119 DISALLOW_COPY_AND_ASSIGN(AuthenticateMessage);
120};
121
122
repo syncdc085c82012-12-28 08:54:41 -0800123class CancelRemainOnChannelMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700124 public:
125 static const uint8_t kCommand;
126 static const char kCommandString[];
127
Christopher Wiley764538d2012-11-09 10:58:23 -0800128 CancelRemainOnChannelMessage()
repo syncdc085c82012-12-28 08:54:41 -0800129 : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700130
Wade Guthrie0d438532012-05-18 14:18:50 -0700131 private:
132 DISALLOW_COPY_AND_ASSIGN(CancelRemainOnChannelMessage);
133};
134
135
repo syncdc085c82012-12-28 08:54:41 -0800136class ConnectMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700137 public:
138 static const uint8_t kCommand;
139 static const char kCommandString[];
140
repo syncdc085c82012-12-28 08:54:41 -0800141 ConnectMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700142
Wade Guthrie0d438532012-05-18 14:18:50 -0700143 private:
144 DISALLOW_COPY_AND_ASSIGN(ConnectMessage);
145};
146
147
repo syncdc085c82012-12-28 08:54:41 -0800148class DeauthenticateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700149 public:
150 static const uint8_t kCommand;
151 static const char kCommandString[];
152
repo syncdc085c82012-12-28 08:54:41 -0800153 DeauthenticateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700154
Wade Guthrie0d438532012-05-18 14:18:50 -0700155 private:
156 DISALLOW_COPY_AND_ASSIGN(DeauthenticateMessage);
157};
158
159
repo syncdc085c82012-12-28 08:54:41 -0800160class DeleteStationMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700161 public:
162 static const uint8_t kCommand;
163 static const char kCommandString[];
164
repo syncdc085c82012-12-28 08:54:41 -0800165 DeleteStationMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700166
Wade Guthrie0d438532012-05-18 14:18:50 -0700167 private:
168 DISALLOW_COPY_AND_ASSIGN(DeleteStationMessage);
169};
170
171
repo syncdc085c82012-12-28 08:54:41 -0800172class DisassociateMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700173 public:
174 static const uint8_t kCommand;
175 static const char kCommandString[];
176
repo syncdc085c82012-12-28 08:54:41 -0800177 DisassociateMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700178
Wade Guthrie0d438532012-05-18 14:18:50 -0700179 private:
180 DISALLOW_COPY_AND_ASSIGN(DisassociateMessage);
181};
182
183
repo syncdc085c82012-12-28 08:54:41 -0800184class DisconnectMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700185 public:
186 static const uint8_t kCommand;
187 static const char kCommandString[];
188
repo syncdc085c82012-12-28 08:54:41 -0800189 DisconnectMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700190
Wade Guthrie0d438532012-05-18 14:18:50 -0700191 private:
192 DISALLOW_COPY_AND_ASSIGN(DisconnectMessage);
193};
194
195
repo syncdc085c82012-12-28 08:54:41 -0800196class FrameTxStatusMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700197 public:
198 static const uint8_t kCommand;
199 static const char kCommandString[];
200
repo syncdc085c82012-12-28 08:54:41 -0800201 FrameTxStatusMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700202
Wade Guthrie0d438532012-05-18 14:18:50 -0700203 private:
204 DISALLOW_COPY_AND_ASSIGN(FrameTxStatusMessage);
205};
206
repo sync0efa9f02012-12-28 13:40:20 -0800207class 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
Paul Stewart7cd45722013-08-12 14:50:14 -0700218class GetStationMessage : public Nl80211Message {
219 public:
220 static const uint8_t kCommand;
221 static const char kCommandString[];
222
223 GetStationMessage();
224
225 private:
226 DISALLOW_COPY_AND_ASSIGN(GetStationMessage);
227};
228
Wade Guthrie1f355e82013-04-11 15:46:12 -0700229class GetWiphyMessage : public Nl80211Message {
230 public:
231 static const uint8_t kCommand;
232 static const char kCommandString[];
233
Wade Guthrie92d06362013-04-25 15:41:30 -0700234 GetWiphyMessage();
Wade Guthrie1f355e82013-04-11 15:46:12 -0700235
236 private:
237 DISALLOW_COPY_AND_ASSIGN(GetWiphyMessage);
238};
239
Wade Guthrie0d438532012-05-18 14:18:50 -0700240
repo syncdc085c82012-12-28 08:54:41 -0800241class JoinIbssMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700242 public:
243 static const uint8_t kCommand;
244 static const char kCommandString[];
245
repo syncdc085c82012-12-28 08:54:41 -0800246 JoinIbssMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700247
Wade Guthrie0d438532012-05-18 14:18:50 -0700248 private:
249 DISALLOW_COPY_AND_ASSIGN(JoinIbssMessage);
250};
251
252
repo syncdc085c82012-12-28 08:54:41 -0800253class MichaelMicFailureMessage : 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 MichaelMicFailureMessage() : 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(MichaelMicFailureMessage);
262};
263
264
repo syncdc085c82012-12-28 08:54:41 -0800265class NewScanResultsMessage : 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 NewScanResultsMessage() : 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(NewScanResultsMessage);
274};
275
276
repo syncdc085c82012-12-28 08:54:41 -0800277class NewStationMessage : 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 NewStationMessage() : 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(NewStationMessage);
286};
287
288
Wade Guthrie1f355e82013-04-11 15:46:12 -0700289class NewWiphyMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700290 public:
291 static const uint8_t kCommand;
292 static const char kCommandString[];
293
Wade Guthrie1f355e82013-04-11 15:46:12 -0700294 NewWiphyMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700295
Wade Guthrie0d438532012-05-18 14:18:50 -0700296 private:
Wade Guthrie1f355e82013-04-11 15:46:12 -0700297 DISALLOW_COPY_AND_ASSIGN(NewWiphyMessage);
Wade Guthrie0d438532012-05-18 14:18:50 -0700298};
299
300
repo syncdc085c82012-12-28 08:54:41 -0800301class NotifyCqmMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700302 public:
303 static const uint8_t kCommand;
304 static const char kCommandString[];
305
repo syncdc085c82012-12-28 08:54:41 -0800306 NotifyCqmMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700307
Wade Guthrie0d438532012-05-18 14:18:50 -0700308 private:
309 DISALLOW_COPY_AND_ASSIGN(NotifyCqmMessage);
310};
311
312
repo syncdc085c82012-12-28 08:54:41 -0800313class PmksaCandidateMessage : 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 PmksaCandidateMessage() : 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(PmksaCandidateMessage);
322};
323
324
repo syncdc085c82012-12-28 08:54:41 -0800325class RegBeaconHintMessage : 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 RegBeaconHintMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700331
Wade Guthrie0d438532012-05-18 14:18:50 -0700332 private:
Wade Guthrie0d438532012-05-18 14:18:50 -0700333 DISALLOW_COPY_AND_ASSIGN(RegBeaconHintMessage);
334};
335
336
repo syncdc085c82012-12-28 08:54:41 -0800337class RegChangeMessage : 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 RegChangeMessage() : Nl80211Message(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700343
Wade Guthrie0d438532012-05-18 14:18:50 -0700344 private:
345 DISALLOW_COPY_AND_ASSIGN(RegChangeMessage);
346};
347
348
repo syncdc085c82012-12-28 08:54:41 -0800349class RemainOnChannelMessage : 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 RemainOnChannelMessage() : 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(RemainOnChannelMessage);
358};
359
360
repo syncdc085c82012-12-28 08:54:41 -0800361class RoamMessage : 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 RoamMessage() : 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(RoamMessage);
370};
371
372
repo syncdc085c82012-12-28 08:54:41 -0800373class ScanAbortedMessage : 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 ScanAbortedMessage() : 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(ScanAbortedMessage);
382};
383
384
Wade Guthrie71872472013-03-05 10:33:38 -0800385class GetScanMessage : public Nl80211Message {
386 public:
387 static const uint8_t kCommand;
388 static const char kCommandString[];
389
390 GetScanMessage() : Nl80211Message(kCommand, kCommandString) {}
391
392 private:
393 DISALLOW_COPY_AND_ASSIGN(GetScanMessage);
394};
395
396
repo syncdc085c82012-12-28 08:54:41 -0800397class TriggerScanMessage : public Nl80211Message {
Wade Guthrie0d438532012-05-18 14:18:50 -0700398 public:
399 static const uint8_t kCommand;
400 static const char kCommandString[];
401
Wade Guthrieb9c3feb2013-04-25 16:31:19 -0700402 TriggerScanMessage();
Wade Guthrie0d438532012-05-18 14:18:50 -0700403
Wade Guthrie0d438532012-05-18 14:18:50 -0700404 private:
405 DISALLOW_COPY_AND_ASSIGN(TriggerScanMessage);
406};
407
408
Wade Guthrie40d992c2013-04-19 11:10:11 -0700409class UnknownNl80211Message : public Nl80211Message {
410 public:
411 explicit UnknownNl80211Message(uint8_t command)
412 : Nl80211Message(command, "<UNKNOWN NL80211 MESSAGE>"),
413 command_(command) {}
414
415 private:
416 uint8_t command_;
417 DISALLOW_COPY_AND_ASSIGN(UnknownNl80211Message);
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_