blob: 214ef1d6f257ec92aa6086ad9b7991c40ca7a98e [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#include "shill/callback80211_object.h"
6
7#include <string>
8
9#include <base/memory/weak_ptr.h>
Wade Guthrieb1ec8602012-10-18 17:26:14 -070010#include <base/stringprintf.h>
Wade Guthrie64b4c142012-08-20 15:21:01 -070011
12#include "shill/config80211.h"
Wade Guthried4977f22012-08-22 12:37:54 -070013#include "shill/ieee80211.h"
Wade Guthrie64b4c142012-08-20 15:21:01 -070014#include "shill/link_monitor.h"
15#include "shill/logging.h"
repo syncd316eb72012-12-10 15:48:47 -080016#include "shill/nl80211_attribute.h"
repo syncdc085c82012-12-28 08:54:41 -080017#include "shill/nl80211_message.h"
Wade Guthrie64b4c142012-08-20 15:21:01 -070018#include "shill/scope_logger.h"
Wade Guthrie64b4c142012-08-20 15:21:01 -070019
20using base::Bind;
Wade Guthrieb1ec8602012-10-18 17:26:14 -070021using base::StringAppendF;
Wade Guthrie64b4c142012-08-20 15:21:01 -070022using std::string;
23
24namespace shill {
25
Christopher Wileyfe34be02012-11-12 16:02:46 -080026Callback80211Object::Callback80211Object()
Wade Guthrie5d3d6de2012-11-02 11:08:34 -070027 : weak_ptr_factory_(this),
Wade Guthrie71cb0a72013-02-27 10:27:18 -080028 message_handler_(Bind(&Callback80211Object::ReceiveConfig80211Message,
29 weak_ptr_factory_.GetWeakPtr())) {
Wade Guthrie64b4c142012-08-20 15:21:01 -070030}
31
32Callback80211Object::~Callback80211Object() {
Wade Guthrie71cb0a72013-02-27 10:27:18 -080033 DeinstallAsHandler();
Wade Guthrie64b4c142012-08-20 15:21:01 -070034}
35
Wade Guthrie71cb0a72013-02-27 10:27:18 -080036void Callback80211Object::Config80211MessageHandler(
Wade Guthrief48a1952013-03-04 17:33:47 -080037 const NetlinkMessage &message) {
Wade Guthrie8e278612013-02-26 10:32:34 -080038 message.Print(10);
Wade Guthrie64b4c142012-08-20 15:21:01 -070039}
40
Wade Guthrie71cb0a72013-02-27 10:27:18 -080041bool Callback80211Object::InstallAsBroadcastHandler() {
42 return Config80211::GetInstance()->AddBroadcastHandler(message_handler_);
Wade Guthrie64b4c142012-08-20 15:21:01 -070043}
44
Wade Guthrie71cb0a72013-02-27 10:27:18 -080045bool Callback80211Object::DeinstallAsHandler() {
46 return Config80211::GetInstance()->RemoveBroadcastHandler(message_handler_);
Christopher Wileyfe34be02012-11-12 16:02:46 -080047}
48
Wade Guthrief48a1952013-03-04 17:33:47 -080049void Callback80211Object::ReceiveConfig80211Message(const NetlinkMessage &msg) {
Wade Guthrie71cb0a72013-02-27 10:27:18 -080050 Config80211MessageHandler(msg);
Wade Guthrie64b4c142012-08-20 15:21:01 -070051}
52
Wade Guthrie64b4c142012-08-20 15:21:01 -070053} // namespace shill.