Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -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 | // 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 Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 17 | #include <base/memory/weak_ptr.h> |
| 18 | |
| 19 | #include "shill/config80211.h" |
Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -0700 | [diff] [blame] | 20 | |
Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -0700 | [diff] [blame] | 21 | namespace shill { |
| 22 | |
| 23 | class UserBoundNlMessage; |
| 24 | |
| 25 | // Example Config80211 callback object; the callback prints a description of |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 26 | // each message with its attributes. |
Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -0700 | [diff] [blame] | 27 | class Callback80211Object { |
| 28 | public: |
Christopher Wiley | fe34be0 | 2012-11-12 16:02:46 -0800 | [diff] [blame^] | 29 | Callback80211Object(); |
Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -0700 | [diff] [blame] | 30 | virtual ~Callback80211Object(); |
| 31 | |
Christopher Wiley | fe34be0 | 2012-11-12 16:02:46 -0800 | [diff] [blame^] | 32 | bool InstallAsBroadcastCallback(); |
Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -0700 | [diff] [blame] | 33 | bool DeinstallAsCallback(); |
| 34 | |
Christopher Wiley | fe34be0 | 2012-11-12 16:02:46 -0800 | [diff] [blame^] | 35 | const Config80211::Callback &callback() const { return callback_; } |
| 36 | protected: |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 37 | // 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 Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 40 | |
Wade Guthrie | 5d3d6de | 2012-11-02 11:08:34 -0700 | [diff] [blame] | 41 | private: |
Christopher Wiley | fe34be0 | 2012-11-12 16:02:46 -0800 | [diff] [blame^] | 42 | void ReceiveConfig80211Message(const UserBoundNlMessage &msg); |
| 43 | |
| 44 | base::WeakPtrFactory<Callback80211Object> weak_ptr_factory_; |
| 45 | Config80211::Callback callback_; |
| 46 | |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 47 | DISALLOW_COPY_AND_ASSIGN(Callback80211Object); |
Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | } // namespace shill |
| 51 | |
| 52 | #endif // SHILL_CALLBACK80211_OBJECT_H |