wake_on_wifi.h revision 96e35cf43e6d5aa2378cdae6fea507e5335d12bb
1d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan// Copyright 2014 The Chromium OS Authors. All rights reserved. 2d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan// Use of this source code is governed by a BSD-style license that can be 3d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan// found in the LICENSE file. 4d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan 5d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan#ifndef SHILL_WAKE_ON_WIFI_H_ 6d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan#define SHILL_WAKE_ON_WIFI_H_ 7d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan 83a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan#include <linux/if_ether.h> 93a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan#include <netinet/ip.h> 103a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan#include <netinet/ip6.h> 113a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan 125f4b175bca4a997f186010c177c44489c8ae95b4Samuel Tan#include <set> 13cb3ecf321c52de1e72cdf037a459cd893b7c51dbSamuel Tan#include <string> 143a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan#include <utility> 153a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan#include <vector> 163a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan 173a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan#include <base/cancelable_callback.h> 183a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan#include <gtest/gtest_prod.h> // for FRIEND_TEST 193a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan#include <base/memory/ref_counted.h> 203a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan#include <base/memory/weak_ptr.h> 213a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan 223a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan#include "shill/callbacks.h" 233a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan#include "shill/ip_address_store.h" 248d6b59704591ba9fad57751858835dc332dbdd37Peter Qiu#include "shill/net/ip_address.h" 2502e3dc3bc6e9fdb475bd13944f1c6764c921abbbPeter Qiu#include "shill/net/netlink_manager.h" 263a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan#include "shill/refptr_types.h" 273a9c098afcd0456734092388d4aa7275716d33aaSamuel Tan 28d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tannamespace shill { 29d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan 30d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tanclass ByteString; 31d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tanclass Error; 323a1bf99b484ad8a9a054518f49046221251d5612Samuel Tanclass EventDispatcher; 333a9c098afcd0456734092388d4aa7275716d33aaSamuel Tanclass GetWakeOnPacketConnMessage; 34a757752df1b85d8af4590b64d0946b7b2bb0779fSamuel Tanclass Manager; 353a9c098afcd0456734092388d4aa7275716d33aaSamuel Tanclass Nl80211Message; 3696e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tanclass PropertyStore; 37d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tanclass SetWakeOnPacketConnMessage; 383a1bf99b484ad8a9a054518f49046221251d5612Samuel Tanclass WiFi; 393a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan 403a1bf99b484ad8a9a054518f49046221251d5612Samuel Tanclass WakeOnWiFi { 413a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan public: 42a757752df1b85d8af4590b64d0946b7b2bb0779fSamuel Tan WakeOnWiFi(NetlinkManager *netlink_manager, EventDispatcher *dispatcher, 43a757752df1b85d8af4590b64d0946b7b2bb0779fSamuel Tan Manager *manager); 44fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan virtual ~WakeOnWiFi(); 453a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan 4696e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan // Registers |store| with properties related to wake on WiFi. 4796e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan void InitPropertyStore(PropertyStore *store); 4896e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan 493a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Types of triggers that can cause the NIC to wake the WiFi device. 503a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan enum WakeOnWiFiTrigger { kIPAddress, kDisconnect }; 513a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan 523a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Enable the NIC to wake on packets received from |ip_endpoint|. 533a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Note: The actual programming of the NIC only happens before the system 543a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // suspends, in |OnBeforeSuspend|. 553a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void AddWakeOnPacketConnection(const IPAddress &ip_endpoint, Error *error); 563a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Remove rule to wake on packets received from |ip_endpoint| from the NIC. 573a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Note: The actual programming of the NIC only happens before the system 583a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // suspends, in |OnBeforeSuspend|. 593a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void RemoveWakeOnPacketConnection(const IPAddress &ip_endpoint, Error *error); 603a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Remove all rules to wake on incoming packets from the NIC. 613a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Note: The actual programming of the NIC only happens before the system 623a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // suspends, in |OnBeforeSuspend|. 633a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void RemoveAllWakeOnPacketConnections(Error *error); 643a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Given a NL80211_CMD_NEW_WIPHY message |nl80211_message|, parses the 653a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // wake on wifi capabilities of the NIC and set relevant members of this 663a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // WakeOnWiFi object to reflect the supported capbilities. 673a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void ParseWakeOnWiFiCapabilities(const Nl80211Message &nl80211_message); 683a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Given a NL80211_CMD_NEW_WIPHY message |nl80211_message|, parses the 693a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // wiphy index of the NIC and sets |wiphy_index_| with the parsed index. 703a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void ParseWiphyIndex(const Nl80211Message &nl80211_message); 713a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Performs pre-suspend actions relevant to wake on wireless functionality. 72fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan virtual void OnBeforeSuspend(const ResultCallback &callback); 733a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Performs post-resume actions relevant to wake on wireless functionality. 74fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan virtual void OnAfterResume(); 753a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan 763a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan private: 773a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan friend class WakeOnWiFiTest; // access to several members for tests 783a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan friend class WiFiObjectTest; // netlink_manager_ 79fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan // Tests that need kWakeOnWiFiDisabled. 80fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan FRIEND_TEST(WakeOnWiFiTest, AddWakeOnPacketConnection_ReturnsError); 81fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan FRIEND_TEST(WakeOnWiFiTest, RemoveWakeOnPacketConnection_ReturnsError); 82fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan FRIEND_TEST(WakeOnWiFiTest, RemoveAllWakeOnPacketConnections_ReturnsError); 833a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan FRIEND_TEST(WakeOnWiFiTest, ParseWiphyIndex_Success); // kDefaultWiphyIndex 84fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan // Tests that need kMaxSetWakeOnPacketRetries. 853a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan FRIEND_TEST(WakeOnWiFiTest, 863a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan RetrySetWakeOnPacketConnections_LessThanMaxRetries); 873a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan FRIEND_TEST(WakeOnWiFiTest, 883a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan RetrySetWakeOnPacketConnections_MaxAttemptsWithCallbackSet); 893a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan FRIEND_TEST(WakeOnWiFiTest, 903a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan RetrySetWakeOnPacketConnections_MaxAttemptsCallbackUnset); 913a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan 92fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan static const char kWakeOnIPAddressPatternsNotSupported[]; 93fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan static const char kWakeOnPacketDisabled[]; 94fb02175e039a683cf9ac875ba0924858de6a08ffSamuel Tan static const char kWakeOnWiFiDisabled[]; 953a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static const uint32_t kDefaultWiphyIndex; 963a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static const int kVerifyWakeOnWiFiSettingsDelaySeconds; 973a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static const int kMaxSetWakeOnPacketRetries; 983a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan 9996e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan std::string GetWakeOnWiFiFeaturesEnabled(Error *error); 10096e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan bool SetWakeOnWiFiFeaturesEnabled(const std::string &enabled, Error *error); 101740ee07e13d98ee9e0535ffea391326c8da13499Samuel Tan // Helper function to run and reset |suspend_actions_done_callback_|. 102740ee07e13d98ee9e0535ffea391326c8da13499Samuel Tan void RunAndResetSuspendActionsDoneCallback(const Error &error); 1033a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Used for comparison of ByteString pairs in a set. 1043a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static bool ByteStringPairIsLessThan( 1053a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan const std::pair<ByteString, ByteString> &lhs, 1063a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan const std::pair<ByteString, ByteString> &rhs); 1073a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Creates a mask which specifies which bytes in pattern of length 1083a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // |pattern_len| to match against. Bits |offset| to |pattern_len| - 1 are set, 1093a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // which bits 0 to bits 0 to |offset| - 1 are unset. This mask is saved in 1103a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // |mask|. 1113a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static void SetMask(ByteString *mask, uint32_t pattern_len, uint32_t offset); 1123a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Creates a pattern and mask for a NL80211 message that programs the NIC to 1133a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // wake on packets originating from IP address |ip_addr|. The pattern and mask 1143a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // are saved in |pattern| and |mask| respectively. Returns true iff the 1153a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // pattern and mask are successfully created and written to |pattern| and 1163a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // |mask| respectively. 1173a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static bool CreateIPAddressPatternAndMask(const IPAddress &ip_addr, 1183a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan ByteString *pattern, 1193a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan ByteString *mask); 1203a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static void CreateIPV4PatternAndMask(const IPAddress &ip_addr, 1213a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan ByteString *pattern, ByteString *mask); 1223a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static void CreateIPV6PatternAndMask(const IPAddress &ip_addr, 1233a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan ByteString *pattern, ByteString *mask); 1243a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Creates and sets an attribute in a NL80211 message |msg| which indicates 1253a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // the index of the wiphy interface to program. Returns true iff |msg| is 1263a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // successfully configured. 1273a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static bool ConfigureWiphyIndex(Nl80211Message *msg, int32_t index); 1283a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Creates and sets attributes in an SetWakeOnPacketConnMessage |msg| so that 1293a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // the message will disable wake-on-packet functionality of the NIC with wiphy 1303a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // index |wiphy_index|. Returns true iff |msg| is successfully configured. 1313a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // NOTE: Assumes that |msg| has not been altered since construction. 1323a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static bool ConfigureDisableWakeOnWiFiMessage(SetWakeOnPacketConnMessage *msg, 1333a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan uint32_t wiphy_index, 1343a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan Error *error); 1353a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Creates and sets attributes in a SetWakeOnPacketConnMessage |msg| 1363a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // so that the message will program the NIC with wiphy index |wiphy_index| 1373a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // with wake on wireless triggers in |trigs|. If |trigs| contains the 1383a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // kIPAddress trigger, the NIC is programmed to wake on packets from the 1393a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // IP addresses in |addrs|. Returns true iff |msg| is successfully configured. 1403a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // NOTE: Assumes that |msg| has not been altered since construction. 1413a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static bool ConfigureSetWakeOnWiFiSettingsMessage( 1423a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan SetWakeOnPacketConnMessage *msg, const std::set<WakeOnWiFiTrigger> &trigs, 1433a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan const IPAddressStore &addrs, uint32_t wiphy_index, Error *error); 1443a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Helper function to ConfigureSetWakeOnWiFiSettingsMessage that creates a 1453a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // single nested attribute inside the attribute list referenced by |patterns| 1463a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // representing a wake-on-packet pattern matching rule with index |patnum|. 1473a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Returns true iff the attribute is successfully created and set. 1483a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // NOTE: |patterns| is assumed to reference the nested attribute list 1493a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // NL80211_WOWLAN_TRIG_PKT_PATTERN. 1503a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // NOTE: |patnum| should be unique across multiple calls to this function to 1513a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // prevent the formation of a erroneous nl80211 message or the overwriting of 1523a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // pattern matching rules. 1533a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static bool CreateSinglePattern(const IPAddress &ip_addr, 1543a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan AttributeListRefPtr patterns, uint8_t patnum, 1553a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan Error *error); 1563a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Creates and sets attributes in an GetWakeOnPacketConnMessage msg| so that 1573a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // the message will request for wake-on-packet settings information from the 1583a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // NIC with wiphy index |wiphy_index|. Returns true iff |msg| is successfully 1593a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // configured. 1603a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // NOTE: Assumes that |msg| has not been altered since construction. 1613a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static bool ConfigureGetWakeOnWiFiSettingsMessage( 1623a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan GetWakeOnPacketConnMessage *msg, uint32_t wiphy_index, Error *error); 1633a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Given a NL80211_CMD_GET_WOWLAN response or NL80211_CMD_SET_WOWLAN request 1643a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // |msg|, returns true iff the wake-on-wifi trigger settings in |msg| match 1653a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // those in |trigs|. Checks that source IP addresses in |msg| match those in 1663a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // |addrs| if the kIPAddress flag is in |trigs|. 1673a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static bool WakeOnWiFiSettingsMatch(const Nl80211Message &msg, 1683a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan const std::set<WakeOnWiFiTrigger> &trigs, 1693a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan const IPAddressStore &addrs); 170742866741cd8902bfabd3d9731ccc6b4d5052de6Samuel Tan // Handler for NL80211 message error responses from NIC wake on WiFi setting 171742866741cd8902bfabd3d9731ccc6b4d5052de6Samuel Tan // programming attempts. 172742866741cd8902bfabd3d9731ccc6b4d5052de6Samuel Tan void OnWakeOnWiFiSettingsErrorResponse( 173742866741cd8902bfabd3d9731ccc6b4d5052de6Samuel Tan NetlinkManager::AuxilliaryMessageType type, 174742866741cd8902bfabd3d9731ccc6b4d5052de6Samuel Tan const NetlinkMessage *raw_message); 1753a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Message handler for NL80211_CMD_SET_WOWLAN responses. 1763a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan static void OnSetWakeOnPacketConnectionResponse( 1773a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan const Nl80211Message &nl80211_message); 1783a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Request wake on WiFi settings for this WiFi device. 1793a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void RequestWakeOnPacketSettings(); 1803a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Verify that the wake on WiFi settings programmed into the NIC match 1813a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // those recorded locally for this device in |wake_on_packet_connections_| 1823a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // and |wake_on_wifi_triggers_|. 1833a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void VerifyWakeOnWiFiSettings(const Nl80211Message &nl80211_message); 1843a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Sends an NL80211 message to program the NIC with wake on WiFi settings 1853a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // configured in |wake_on_packet_connections_| and |wake_on_wifi_triggers_|. 1863a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // If |wake_on_wifi_triggers_| is empty, calls |DisableWakeOnWiFi|. 1873a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void ApplyWakeOnWiFiSettings(); 1883a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Helper function called by |ApplyWakeOnWiFiSettings| that sends an NL80211 1893a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // message to program the NIC to disable wake on WiFi. 1903a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void DisableWakeOnWiFi(); 1913a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Calls |ApplyWakeOnWiFiSettings| and counts this call as 1923a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // a retry. If |kMaxSetWakeOnPacketRetries| retries have already been 1933a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // performed, resets counter and returns. 1943a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan void RetrySetWakeOnPacketConnections(); 1953a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan 196cb3ecf321c52de1e72cdf037a459cd893b7c51dbSamuel Tan // Utility functions to check which wake on WiFi features are currently 19796e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan // enabled based on the descriptor |wake_on_wifi_features_enabled_|. 19896e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan bool WakeOnPacketEnabled(); 19996e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan bool WakeOnSSIDEnabled(); 20096e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan bool WakeOnWiFiFeaturesDisabled(); 201cb3ecf321c52de1e72cdf037a459cd893b7c51dbSamuel Tan 2023a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Pointers to objects owned by the WiFi object that created this object. 2033a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan EventDispatcher *dispatcher_; 2043a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan NetlinkManager *netlink_manager_; 205a757752df1b85d8af4590b64d0946b7b2bb0779fSamuel Tan Manager *manager_; 2063a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Executes after the NIC's wake-on-packet settings are configured via 2073a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // NL80211 messages to verify that the new configuration has taken effect. 2083a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Calls RequestWakeOnPacketSettings. 2093a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan base::CancelableClosure verify_wake_on_packet_settings_callback_; 2103a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Callback to be invoked after all suspend actions finish executing. 2113a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan ResultCallback suspend_actions_done_callback_; 2123a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Number of retry attempts to program the NIC's wake-on-packet settings. 2133a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan int num_set_wake_on_packet_retries_; 2143a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Keeps track of triggers that the NIC will be programmed to wake from 2153a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // while suspended. 2163a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan std::set<WakeOnWiFi::WakeOnWiFiTrigger> wake_on_wifi_triggers_; 2173a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Keeps track of what wake on wifi triggers this WiFi device supports. 2183a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan std::set<WakeOnWiFi::WakeOnWiFiTrigger> wake_on_wifi_triggers_supported_; 2193a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Max number of patterns this WiFi device can be programmed to wake on 2203a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // at one time. 2213a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan size_t wake_on_wifi_max_patterns_; 2223a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // Keeps track of IP addresses whose packets this device will wake upon 2233a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan // receiving while the device is suspended. 2243a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan IPAddressStore wake_on_packet_connections_; 2253a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan uint32_t wiphy_index_; 2263a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan bool wiphy_index_received_; 22796e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan // Describes the wake on WiFi features that are currently enabled. 22896e35cf43e6d5aa2378cdae6fea507e5335d12bbSamuel Tan std::string wake_on_wifi_features_enabled_; 2293a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan base::WeakPtrFactory<WakeOnWiFi> weak_ptr_factory_; 230d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan 2313a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan DISALLOW_COPY_AND_ASSIGN(WakeOnWiFi); 2323a1bf99b484ad8a9a054518f49046221251d5612Samuel Tan}; 233d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan 234d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan} // namespace shill 235d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan 236d03b95db5d05928ea63fc9f8aac5151e93c43a2fSamuel Tan#endif // SHILL_WAKE_ON_WIFI_H_ 237