blob: 68152c25b048c8825d5a384449918012ed7e87d8 [file] [log] [blame]
Wade Guthrie64b4c142012-08-20 15:21:01 -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// This class is a callback object that observes all nl80211 events that come
6// up from the kernel.
7
8#ifndef SHILL_CALLBACK80211_OBJECT_H
9#define SHILL_CALLBACK80211_OBJECT_H
10
11#include <iomanip>
12#include <map>
13#include <string>
14
15#include <base/basictypes.h>
16#include <base/bind.h>
Wade Guthrie5020b572012-10-12 15:51:14 -070017#include <base/memory/weak_ptr.h>
18
19#include "shill/config80211.h"
Wade Guthrie64b4c142012-08-20 15:21:01 -070020
Wade Guthrie64b4c142012-08-20 15:21:01 -070021namespace shill {
22
23class UserBoundNlMessage;
24
25// Example Config80211 callback object; the callback prints a description of
Wade Guthrie5020b572012-10-12 15:51:14 -070026// each message with its attributes.
Wade Guthrie64b4c142012-08-20 15:21:01 -070027class Callback80211Object {
28 public:
Christopher Wileyfe34be02012-11-12 16:02:46 -080029 Callback80211Object();
Wade Guthrie64b4c142012-08-20 15:21:01 -070030 virtual ~Callback80211Object();
31
Christopher Wileyfe34be02012-11-12 16:02:46 -080032 bool InstallAsBroadcastCallback();
Wade Guthrie64b4c142012-08-20 15:21:01 -070033 bool DeinstallAsCallback();
34
Christopher Wileyfe34be02012-11-12 16:02:46 -080035 const Config80211::Callback &callback() const { return callback_; }
36 protected:
Wade Guthrie5020b572012-10-12 15:51:14 -070037 // When installed, this is the method Config80211 will call when it gets a
38 // message from the mac80211 drivers.
39 virtual void Config80211MessageCallback(const UserBoundNlMessage &msg);
Wade Guthried4977f22012-08-22 12:37:54 -070040
Wade Guthrie5d3d6de2012-11-02 11:08:34 -070041 private:
Christopher Wileyfe34be02012-11-12 16:02:46 -080042 void ReceiveConfig80211Message(const UserBoundNlMessage &msg);
43
44 base::WeakPtrFactory<Callback80211Object> weak_ptr_factory_;
45 Config80211::Callback callback_;
46
Wade Guthrie5020b572012-10-12 15:51:14 -070047 DISALLOW_COPY_AND_ASSIGN(Callback80211Object);
Wade Guthrie64b4c142012-08-20 15:21:01 -070048};
49
50} // namespace shill
51
52#endif // SHILL_CALLBACK80211_OBJECT_H