blob: 6ff50c01f797e4a507fc30ce9aff09e4ddff3be0 [file] [log] [blame]
Wade Guthrie5020b572012-10-12 15:51:14 -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
Wade Guthrie89e6cb32013-03-07 08:03:45 -08008#ifndef SHILL_CALLBACK80211_METRICS_H_
9#define SHILL_CALLBACK80211_METRICS_H_
Wade Guthrie5020b572012-10-12 15:51:14 -070010
Wade Guthrie5020b572012-10-12 15:51:14 -070011#include <base/basictypes.h>
Wade Guthriec6c81962013-03-06 15:47:13 -080012#include <base/memory/weak_ptr.h>
Wade Guthrie5020b572012-10-12 15:51:14 -070013
Wade Guthriebb9fca22013-04-10 17:21:42 -070014#include "shill/netlink_manager.h"
Wade Guthrie5020b572012-10-12 15:51:14 -070015
16namespace shill {
17
Wade Guthrie5020b572012-10-12 15:51:14 -070018class Metrics;
Wade Guthriebb9fca22013-04-10 17:21:42 -070019class NetlinkManager;
Wade Guthriec6c81962013-03-06 15:47:13 -080020class NetlinkMessage;
Wade Guthrie5020b572012-10-12 15:51:14 -070021
Wade Guthriebb9fca22013-04-10 17:21:42 -070022// NetlinkManager callback object that sends stuff to UMA metrics.
Wade Guthriec6c81962013-03-06 15:47:13 -080023class Callback80211Metrics :
24 public base::SupportsWeakPtr<Callback80211Metrics> {
Wade Guthrie5020b572012-10-12 15:51:14 -070025 public:
Wade Guthriebb9fca22013-04-10 17:21:42 -070026 Callback80211Metrics(const NetlinkManager &netlink_manager, Metrics *metrics);
Wade Guthrie5020b572012-10-12 15:51:14 -070027
Wade Guthriec6c81962013-03-06 15:47:13 -080028 // This retrieves the numerical id for the "nl80211" family of messages.
29 // Should only be called (once) at initialization time but must be called
Wade Guthriebb9fca22013-04-10 17:21:42 -070030 // only after NetlinkManager knows about the "nl80211" family.
31 void InitNl80211FamilyId(const NetlinkManager &netlink_manager);
Wade Guthriec6c81962013-03-06 15:47:13 -080032
Wade Guthriebb9fca22013-04-10 17:21:42 -070033 // Called with each broadcast netlink message that arrives to NetlinkManager.
Wade Guthriec6c81962013-03-06 15:47:13 -080034 // If the message is a deauthenticate message, the method collects the reason
35 // for the deauthentication and communicates those to UMA.
36 void CollectDisconnectStatistics(const NetlinkMessage &msg);
Wade Guthrie5020b572012-10-12 15:51:14 -070037
Christopher Wileyfe34be02012-11-12 16:02:46 -080038 private:
Wade Guthrie5020b572012-10-12 15:51:14 -070039 static const char kMetricLinkDisconnectCount[];
40
41 Metrics *metrics_;
Wade Guthriec6c81962013-03-06 15:47:13 -080042 uint16_t nl80211_message_type_;
Wade Guthrie5020b572012-10-12 15:51:14 -070043
Wade Guthrie5020b572012-10-12 15:51:14 -070044 DISALLOW_COPY_AND_ASSIGN(Callback80211Metrics);
45};
46
47} // namespace shill
48
Wade Guthrie89e6cb32013-03-07 08:03:45 -080049#endif // SHILL_CALLBACK80211_METRICS_H_