blob: 120cb1c6f6477462e1a1bc29338fb3c3ccdeb987 [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
Wade Guthrie64b4c142012-08-20 15:21:01 -070011#include <base/basictypes.h>
Wade Guthrie5020b572012-10-12 15:51:14 -070012#include <base/memory/weak_ptr.h>
13
14#include "shill/config80211.h"
Wade Guthrie64b4c142012-08-20 15:21:01 -070015
Wade Guthrie64b4c142012-08-20 15:21:01 -070016namespace shill {
17
18class UserBoundNlMessage;
19
20// Example Config80211 callback object; the callback prints a description of
Wade Guthrie5020b572012-10-12 15:51:14 -070021// each message with its attributes.
Wade Guthrie64b4c142012-08-20 15:21:01 -070022class Callback80211Object {
23 public:
Christopher Wileyfe34be02012-11-12 16:02:46 -080024 Callback80211Object();
Wade Guthrie64b4c142012-08-20 15:21:01 -070025 virtual ~Callback80211Object();
26
Christopher Wileyfe34be02012-11-12 16:02:46 -080027 bool InstallAsBroadcastCallback();
Wade Guthrie64b4c142012-08-20 15:21:01 -070028 bool DeinstallAsCallback();
29
Christopher Wileyfe34be02012-11-12 16:02:46 -080030 const Config80211::Callback &callback() const { return callback_; }
31 protected:
Wade Guthrie5020b572012-10-12 15:51:14 -070032 // When installed, this is the method Config80211 will call when it gets a
33 // message from the mac80211 drivers.
34 virtual void Config80211MessageCallback(const UserBoundNlMessage &msg);
Wade Guthried4977f22012-08-22 12:37:54 -070035
Wade Guthrie5d3d6de2012-11-02 11:08:34 -070036 private:
Christopher Wileyfe34be02012-11-12 16:02:46 -080037 void ReceiveConfig80211Message(const UserBoundNlMessage &msg);
38
39 base::WeakPtrFactory<Callback80211Object> weak_ptr_factory_;
40 Config80211::Callback callback_;
41
Wade Guthrie5020b572012-10-12 15:51:14 -070042 DISALLOW_COPY_AND_ASSIGN(Callback80211Object);
Wade Guthrie64b4c142012-08-20 15:21:01 -070043};
44
45} // namespace shill
46
47#endif // SHILL_CALLBACK80211_OBJECT_H