blob: cd6dbc0b9253757fe112d3de1dfb916c7dc537a0 [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
5#ifndef SHILL_USER_BOUND_NLMESSAGE_H_
6#define SHILL_USER_BOUND_NLMESSAGE_H_
7
Wade Guthrie8343f7f2012-12-04 13:52:32 -08008#include <linux/nl80211.h>
9
Wade Guthrie0d438532012-05-18 14:18:50 -070010#include <iomanip>
11#include <map>
Wade Guthrie0d438532012-05-18 14:18:50 -070012#include <string>
Wade Guthrie8343f7f2012-12-04 13:52:32 -080013#include <vector>
Wade Guthrie0d438532012-05-18 14:18:50 -070014
15#include <base/basictypes.h>
16#include <base/bind.h>
17#include <base/lazy_instance.h>
18#include <gtest/gtest.h>
19
repo sync90ee0fa2012-12-18 10:08:08 -080020#include "shill/attribute_list.h"
repo sync1538d442012-12-20 15:24:35 -080021#include "shill/byte_string.h"
Wade Guthrie16196242012-11-20 15:53:52 -080022
Wade Guthrie0d438532012-05-18 14:18:50 -070023struct nlattr;
24struct nlmsghdr;
25
26namespace shill {
27
28// Class for messages received from libnl.
29class UserBoundNlMessage {
30 public:
Wade Guthrie8343f7f2012-12-04 13:52:32 -080031 static const unsigned int kEthernetAddressBytes;
Wade Guthrie0d438532012-05-18 14:18:50 -070032 static const char kBogusMacAddress[];
33
Christopher Wiley764538d2012-11-09 10:58:23 -080034 UserBoundNlMessage(uint8 message_type, const char *message_type_string)
35 : message_(NULL),
36 message_type_(message_type),
repo sync90ee0fa2012-12-18 10:08:08 -080037 message_type_string_(message_type_string) {}
38 virtual ~UserBoundNlMessage() {}
Wade Guthrie0d438532012-05-18 14:18:50 -070039
40 // Non-trivial initialization.
41 virtual bool Init(nlattr *tb[NL80211_ATTR_MAX + 1], nlmsghdr *msg);
42
Wade Guthrie0d438532012-05-18 14:18:50 -070043 // Message ID is equivalent to the message's sequence number.
44 uint32_t GetId() const;
45
repo sync90ee0fa2012-12-18 10:08:08 -080046 const AttributeList &attributes() const { return attributes_; }
Wade Guthrie0d438532012-05-18 14:18:50 -070047
repo sync90ee0fa2012-12-18 10:08:08 -080048 // TODO(wdg): This needs to be moved to AttributeMac.
Wade Guthrie0d438532012-05-18 14:18:50 -070049 // Helper function to provide a string for a MAC address. If no attribute
50 // is found, this method returns 'false'. On any error with a non-NULL
51 // |value|, this method sets |value| to a bogus MAC address.
repo sync12cca802012-12-19 17:34:22 -080052 bool GetMacAttributeString(nl80211_attrs id, std::string *value) const;
Wade Guthrie0d438532012-05-18 14:18:50 -070053
repo sync90ee0fa2012-12-18 10:08:08 -080054 // TODO(wdg): This needs to be moved to AttributeScanFrequencies.
Wade Guthrie0d438532012-05-18 14:18:50 -070055 // Helper function to provide a vector of scan frequencies for attributes
56 // that contain them (such as NL80211_ATTR_SCAN_FREQUENCIES).
repo sync12cca802012-12-19 17:34:22 -080057 bool GetScanFrequenciesAttribute(nl80211_attrs id,
Wade Guthrie0d438532012-05-18 14:18:50 -070058 std::vector<uint32_t> *value) const;
59
repo sync90ee0fa2012-12-18 10:08:08 -080060 // TODO(wdg): This needs to be moved to AttributeScanSSids.
Wade Guthrie0d438532012-05-18 14:18:50 -070061 // Helper function to provide a vector of SSIDs for attributes that contain
62 // them (such as NL80211_ATTR_SCAN_SSIDS).
repo sync12cca802012-12-19 17:34:22 -080063 bool GetScanSsidsAttribute(nl80211_attrs id,
Wade Guthrie0d438532012-05-18 14:18:50 -070064 std::vector<std::string> *value) const;
65
repo sync90ee0fa2012-12-18 10:08:08 -080066 // TODO(wdg): This needs to be moved to AttributeMac.
Wade Guthrie0d438532012-05-18 14:18:50 -070067 // Stringizes the MAC address found in 'arg'. If there are problems (such
68 // as a NULL |arg|), |value| is set to a bogus MAC address.
69 static std::string StringFromMacAddress(const uint8_t *arg);
70
Wade Guthried4977f22012-08-22 12:37:54 -070071 // Returns a string representing the passed-in |status| or |reason|, the
72 // value of which has been acquired from libnl (for example, from the
Wade Guthrie0d438532012-05-18 14:18:50 -070073 // NL80211_ATTR_STATUS_CODE or NL80211_ATTR_REASON_CODE attribute).
Wade Guthried4977f22012-08-22 12:37:54 -070074 static std::string StringFromReason(uint16_t reason);
Wade Guthrie0d438532012-05-18 14:18:50 -070075 static std::string StringFromStatus(uint16_t status);
76
repo sync1538d442012-12-20 15:24:35 -080077 std::string GenericToString() const;
78
Wade Guthrie0d438532012-05-18 14:18:50 -070079 // Returns a string that describes this message.
80 virtual std::string ToString() const { return GetHeaderString(); }
81
Christopher Wiley764538d2012-11-09 10:58:23 -080082 uint8 message_type() const { return message_type_; }
83 const char *message_type_string() const { return message_type_string_; }
84
Wade Guthrie0d438532012-05-18 14:18:50 -070085 protected:
Wade Guthrie0d438532012-05-18 14:18:50 -070086 // Returns a string that should precede all user-bound message strings.
87 virtual std::string GetHeaderString() const;
88
89 // Returns a string that describes the contents of the frame pointed to by
90 // 'attr'.
91 std::string StringFromFrame(nl80211_attrs attr_name) const;
92
93 // Converts key_type to a string.
94 static std::string StringFromKeyType(nl80211_key_type key_type);
95
96 // Returns a string representation of the REG initiator described by the
97 // method's parameter.
98 static std::string StringFromRegInitiator(__u8 initiator);
99
100 // Returns a string based on the SSID found in 'data'. Non-printable
101 // characters are string-ized.
102 static std::string StringFromSsid(const uint8_t len, const uint8_t *data);
103
104 private:
Wade Guthrie0d438532012-05-18 14:18:50 -0700105 friend class Config80211Test;
106 FRIEND_TEST(Config80211Test, NL80211_CMD_NOTIFY_CQM);
107
108 static const uint32_t kIllegalMessage;
Wade Guthrie0d438532012-05-18 14:18:50 -0700109
110 nlmsghdr *message_;
Christopher Wiley764538d2012-11-09 10:58:23 -0800111 const uint8 message_type_;
112 const char *message_type_string_;
Wade Guthried4977f22012-08-22 12:37:54 -0700113 static std::map<uint16_t, std::string> *reason_code_string_;
114 static std::map<uint16_t, std::string> *status_code_string_;
repo sync90ee0fa2012-12-18 10:08:08 -0800115
116 AttributeList attributes_;
Wade Guthrie0d438532012-05-18 14:18:50 -0700117
118 DISALLOW_COPY_AND_ASSIGN(UserBoundNlMessage);
119};
120
121class Nl80211Frame {
122 public:
123 enum Type {
124 kAssocResponseFrameType = 0x10,
125 kReassocResponseFrameType = 0x30,
126 kAssocRequestFrameType = 0x00,
127 kReassocRequestFrameType = 0x20,
128 kAuthFrameType = 0xb0,
129 kDisassocFrameType = 0xa0,
130 kDeauthFrameType = 0xc0,
131 kIllegalFrameType = 0xff
132 };
133
repo syncd316eb72012-12-10 15:48:47 -0800134 explicit Nl80211Frame(const ByteString &init);
Wade Guthried4977f22012-08-22 12:37:54 -0700135 bool ToString(std::string *output) const;
136 bool IsEqual(const Nl80211Frame &other) const;
137 uint16_t reason() const { return reason_; }
138 uint16_t status() const { return status_; }
Wade Guthrie0d438532012-05-18 14:18:50 -0700139
140 private:
141 static const uint8_t kMinimumFrameByteCount;
142 static const uint8_t kFrameTypeMask;
143
144 std::string mac_from_;
145 std::string mac_to_;
146 uint8_t frame_type_;
Wade Guthried4977f22012-08-22 12:37:54 -0700147 uint16_t reason_;
Wade Guthrie0d438532012-05-18 14:18:50 -0700148 uint16_t status_;
Wade Guthrie8343f7f2012-12-04 13:52:32 -0800149 ByteString frame_;
Wade Guthrie0d438532012-05-18 14:18:50 -0700150
151 DISALLOW_COPY_AND_ASSIGN(Nl80211Frame);
152};
153
154//
155// Specific UserBoundNlMessage types.
156//
157
158class AssociateMessage : public UserBoundNlMessage {
159 public:
160 static const uint8_t kCommand;
161 static const char kCommandString[];
162
Christopher Wiley764538d2012-11-09 10:58:23 -0800163 AssociateMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700164
Wade Guthrie0d438532012-05-18 14:18:50 -0700165 virtual std::string ToString() const;
166
167 private:
168 DISALLOW_COPY_AND_ASSIGN(AssociateMessage);
169};
170
171
172class AuthenticateMessage : public UserBoundNlMessage {
173 public:
174 static const uint8_t kCommand;
175 static const char kCommandString[];
176
Christopher Wiley764538d2012-11-09 10:58:23 -0800177 AuthenticateMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700178
Wade Guthrie0d438532012-05-18 14:18:50 -0700179 virtual std::string ToString() const;
180
181 private:
182 DISALLOW_COPY_AND_ASSIGN(AuthenticateMessage);
183};
184
185
186class CancelRemainOnChannelMessage : public UserBoundNlMessage {
187 public:
188 static const uint8_t kCommand;
189 static const char kCommandString[];
190
Christopher Wiley764538d2012-11-09 10:58:23 -0800191 CancelRemainOnChannelMessage()
192 : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700193
Wade Guthrie0d438532012-05-18 14:18:50 -0700194 virtual std::string ToString() const;
195
196 private:
197 DISALLOW_COPY_AND_ASSIGN(CancelRemainOnChannelMessage);
198};
199
200
201class ConnectMessage : public UserBoundNlMessage {
202 public:
203 static const uint8_t kCommand;
204 static const char kCommandString[];
205
Christopher Wiley764538d2012-11-09 10:58:23 -0800206 ConnectMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700207
Wade Guthrie0d438532012-05-18 14:18:50 -0700208 virtual std::string ToString() const;
209
210 private:
211 DISALLOW_COPY_AND_ASSIGN(ConnectMessage);
212};
213
214
215class DeauthenticateMessage : public UserBoundNlMessage {
216 public:
217 static const uint8_t kCommand;
218 static const char kCommandString[];
219
Christopher Wiley764538d2012-11-09 10:58:23 -0800220 DeauthenticateMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700221
Wade Guthrie0d438532012-05-18 14:18:50 -0700222 virtual std::string ToString() const;
223
224 private:
225 DISALLOW_COPY_AND_ASSIGN(DeauthenticateMessage);
226};
227
228
229class DeleteStationMessage : public UserBoundNlMessage {
230 public:
231 static const uint8_t kCommand;
232 static const char kCommandString[];
233
Christopher Wiley764538d2012-11-09 10:58:23 -0800234 DeleteStationMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700235
Wade Guthrie0d438532012-05-18 14:18:50 -0700236 virtual std::string ToString() const;
237
238 private:
239 DISALLOW_COPY_AND_ASSIGN(DeleteStationMessage);
240};
241
242
243class DisassociateMessage : public UserBoundNlMessage {
244 public:
245 static const uint8_t kCommand;
246 static const char kCommandString[];
247
Christopher Wiley764538d2012-11-09 10:58:23 -0800248 DisassociateMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700249
Wade Guthrie0d438532012-05-18 14:18:50 -0700250 virtual std::string ToString() const;
251
252 private:
253 DISALLOW_COPY_AND_ASSIGN(DisassociateMessage);
254};
255
256
257class DisconnectMessage : public UserBoundNlMessage {
258 public:
259 static const uint8_t kCommand;
260 static const char kCommandString[];
261
Christopher Wiley764538d2012-11-09 10:58:23 -0800262 DisconnectMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700263
Wade Guthrie0d438532012-05-18 14:18:50 -0700264 virtual std::string ToString() const;
265
266 private:
267 DISALLOW_COPY_AND_ASSIGN(DisconnectMessage);
268};
269
270
271class FrameTxStatusMessage : public UserBoundNlMessage {
272 public:
273 static const uint8_t kCommand;
274 static const char kCommandString[];
275
Christopher Wiley764538d2012-11-09 10:58:23 -0800276 FrameTxStatusMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700277
Wade Guthrie0d438532012-05-18 14:18:50 -0700278 virtual std::string ToString() const;
279
280 private:
281 DISALLOW_COPY_AND_ASSIGN(FrameTxStatusMessage);
282};
283
284
285class JoinIbssMessage : public UserBoundNlMessage {
286 public:
287 static const uint8_t kCommand;
288 static const char kCommandString[];
289
Christopher Wiley764538d2012-11-09 10:58:23 -0800290 JoinIbssMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700291
Wade Guthrie0d438532012-05-18 14:18:50 -0700292 virtual std::string ToString() const;
293
294 private:
295 DISALLOW_COPY_AND_ASSIGN(JoinIbssMessage);
296};
297
298
299class MichaelMicFailureMessage : public UserBoundNlMessage {
300 public:
301 static const uint8_t kCommand;
302 static const char kCommandString[];
303
Christopher Wiley764538d2012-11-09 10:58:23 -0800304 MichaelMicFailureMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700305
Wade Guthrie0d438532012-05-18 14:18:50 -0700306 virtual std::string ToString() const;
307
308 private:
309 DISALLOW_COPY_AND_ASSIGN(MichaelMicFailureMessage);
310};
311
312
313class NewScanResultsMessage : public UserBoundNlMessage {
314 public:
315 static const uint8_t kCommand;
316 static const char kCommandString[];
317
Christopher Wiley764538d2012-11-09 10:58:23 -0800318 NewScanResultsMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700319
Wade Guthrie0d438532012-05-18 14:18:50 -0700320 virtual std::string ToString() const;
321
322 private:
323 DISALLOW_COPY_AND_ASSIGN(NewScanResultsMessage);
324};
325
326
327class NewStationMessage : public UserBoundNlMessage {
328 public:
329 static const uint8_t kCommand;
330 static const char kCommandString[];
331
Christopher Wiley764538d2012-11-09 10:58:23 -0800332 NewStationMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700333
Wade Guthrie0d438532012-05-18 14:18:50 -0700334 virtual std::string ToString() const;
335
336 private:
337 DISALLOW_COPY_AND_ASSIGN(NewStationMessage);
338};
339
340
341class NewWifiMessage : public UserBoundNlMessage {
342 public:
343 static const uint8_t kCommand;
344 static const char kCommandString[];
345
Christopher Wiley764538d2012-11-09 10:58:23 -0800346 NewWifiMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700347
Wade Guthrie0d438532012-05-18 14:18:50 -0700348 virtual std::string ToString() const;
349
350 private:
351 DISALLOW_COPY_AND_ASSIGN(NewWifiMessage);
352};
353
354
355class NotifyCqmMessage : public UserBoundNlMessage {
356 public:
357 static const uint8_t kCommand;
358 static const char kCommandString[];
359
Christopher Wiley764538d2012-11-09 10:58:23 -0800360 NotifyCqmMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700361
Wade Guthrie0d438532012-05-18 14:18:50 -0700362 virtual std::string ToString() const;
363
364 private:
365 DISALLOW_COPY_AND_ASSIGN(NotifyCqmMessage);
366};
367
368
369class PmksaCandidateMessage : public UserBoundNlMessage {
370 public:
371 static const uint8_t kCommand;
372 static const char kCommandString[];
373
Christopher Wiley764538d2012-11-09 10:58:23 -0800374 PmksaCandidateMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700375
Wade Guthrie0d438532012-05-18 14:18:50 -0700376 virtual std::string ToString() const;
377
378 private:
379 DISALLOW_COPY_AND_ASSIGN(PmksaCandidateMessage);
380};
381
382
383class RegBeaconHintMessage : public UserBoundNlMessage {
384 public:
385 static const uint8_t kCommand;
386 static const char kCommandString[];
387
Christopher Wiley764538d2012-11-09 10:58:23 -0800388 RegBeaconHintMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700389
Wade Guthrie0d438532012-05-18 14:18:50 -0700390 virtual std::string ToString() const;
391
392 private:
393 struct ieee80211_beacon_channel {
394 __u16 center_freq;
395 bool passive_scan;
396 bool no_ibss;
397 };
398
399 // Returns the channel ID calculated from the 802.11 frequency.
400 static int ChannelFromIeee80211Frequency(int freq);
401
402 // Sets values in |chan| based on attributes in |tb|, the array of pointers
403 // to netlink attributes, indexed by attribute type.
404 int ParseBeaconHintChan(const nlattr *tb,
405 ieee80211_beacon_channel *chan) const;
406
407 DISALLOW_COPY_AND_ASSIGN(RegBeaconHintMessage);
408};
409
410
411class RegChangeMessage : public UserBoundNlMessage {
412 public:
413 static const uint8_t kCommand;
414 static const char kCommandString[];
415
Christopher Wiley764538d2012-11-09 10:58:23 -0800416 RegChangeMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700417
Wade Guthrie0d438532012-05-18 14:18:50 -0700418 virtual std::string ToString() const;
419
420 private:
421 DISALLOW_COPY_AND_ASSIGN(RegChangeMessage);
422};
423
424
425class RemainOnChannelMessage : public UserBoundNlMessage {
426 public:
427 static const uint8_t kCommand;
428 static const char kCommandString[];
429
Christopher Wiley764538d2012-11-09 10:58:23 -0800430 RemainOnChannelMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700431
Wade Guthrie0d438532012-05-18 14:18:50 -0700432 virtual std::string ToString() const;
433
434 private:
435 DISALLOW_COPY_AND_ASSIGN(RemainOnChannelMessage);
436};
437
438
439class RoamMessage : public UserBoundNlMessage {
440 public:
441 static const uint8_t kCommand;
442 static const char kCommandString[];
443
Christopher Wiley764538d2012-11-09 10:58:23 -0800444 RoamMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700445
Wade Guthrie0d438532012-05-18 14:18:50 -0700446 virtual std::string ToString() const;
447
448 private:
449 DISALLOW_COPY_AND_ASSIGN(RoamMessage);
450};
451
452
453class ScanAbortedMessage : public UserBoundNlMessage {
454 public:
455 static const uint8_t kCommand;
456 static const char kCommandString[];
457
Christopher Wiley764538d2012-11-09 10:58:23 -0800458 ScanAbortedMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700459
Wade Guthrie0d438532012-05-18 14:18:50 -0700460 virtual std::string ToString() const;
461
462 private:
463 DISALLOW_COPY_AND_ASSIGN(ScanAbortedMessage);
464};
465
466
467class TriggerScanMessage : public UserBoundNlMessage {
468 public:
469 static const uint8_t kCommand;
470 static const char kCommandString[];
471
Christopher Wiley764538d2012-11-09 10:58:23 -0800472 TriggerScanMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700473
Wade Guthrie0d438532012-05-18 14:18:50 -0700474 virtual std::string ToString() const;
475
476 private:
477 DISALLOW_COPY_AND_ASSIGN(TriggerScanMessage);
478};
479
480
481class UnknownMessage : public UserBoundNlMessage {
482 public:
Christopher Wiley764538d2012-11-09 10:58:23 -0800483 explicit UnknownMessage(uint8_t command)
484 : UserBoundNlMessage(command, kCommandString),
485 command_(command) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700486
487 static const uint8_t kCommand;
488 static const char kCommandString[];
489
Wade Guthrie0d438532012-05-18 14:18:50 -0700490 virtual std::string ToString() const;
491
492 private:
493 uint8_t command_;
494
495 DISALLOW_COPY_AND_ASSIGN(UnknownMessage);
496};
497
498
499class UnprotDeauthenticateMessage : public UserBoundNlMessage {
500 public:
501 static const uint8_t kCommand;
502 static const char kCommandString[];
503
Christopher Wiley764538d2012-11-09 10:58:23 -0800504 UnprotDeauthenticateMessage()
505 : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700506
Wade Guthrie0d438532012-05-18 14:18:50 -0700507 virtual std::string ToString() const;
508
509 private:
510 DISALLOW_COPY_AND_ASSIGN(UnprotDeauthenticateMessage);
511};
512
513
514class UnprotDisassociateMessage : public UserBoundNlMessage {
515 public:
516 static const uint8_t kCommand;
517 static const char kCommandString[];
518
Christopher Wiley764538d2012-11-09 10:58:23 -0800519 UnprotDisassociateMessage() : UserBoundNlMessage(kCommand, kCommandString) {}
Wade Guthrie0d438532012-05-18 14:18:50 -0700520
Wade Guthrie0d438532012-05-18 14:18:50 -0700521 virtual std::string ToString() const;
522
523 private:
524 DISALLOW_COPY_AND_ASSIGN(UnprotDisassociateMessage);
525};
526
527
528//
529// Factory class.
530//
531
532class UserBoundNlMessageFactory {
533 public:
534 // Ownership of the message is passed to the caller and, as such, he should
535 // delete it.
536 static UserBoundNlMessage *CreateMessage(nlmsghdr *msg);
537
538 private:
539 DISALLOW_COPY_AND_ASSIGN(UserBoundNlMessageFactory);
540};
541
542
543// UserBoundNlMessageDataCollector - this class is used to collect data to be
544// used for unit tests. It is only invoked in this case.
545
546class UserBoundNlMessageDataCollector {
547 public:
548 // This is a singleton -- use Config80211::GetInstance()->Foo()
549 static UserBoundNlMessageDataCollector *GetInstance();
550
551 void CollectDebugData(const UserBoundNlMessage &message, nlmsghdr *msg);
552
553 protected:
554 friend struct
555 base::DefaultLazyInstanceTraits<UserBoundNlMessageDataCollector>;
556
557 explicit UserBoundNlMessageDataCollector();
558
559 private:
560 // In order to limit the output from this class, I keep track of types I
561 // haven't yet printed.
562 std::map<uint8_t, bool> need_to_print;
563};
564
565} // namespace shill
566
567#endif // SHILL_USER_BOUND_NLMESSAGE_H_