1 //
2 // Copyright (C) 2015 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef PROXY_SHILL_WIFI_CLIENT_H
18 #define PROXY_SHILL_WIFI_CLIENT_H
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <sysexits.h>
23 
24 #include <string>
25 
26 #include <brillo/any.h>
27 #include <brillo/variant_dictionary.h>
28 // Abstract class which defines the interface for the RPC server to talk to Shill.
29 // This helps in abstracting out the underlying protocol that Shill client
30 // needs to use: Dbus, Binder, etc.
31 // TODO: Need to come up with comments explaining what each method needs to do here.
32 class ProxyShillWifiClient {
33  public:
34   enum AutoConnectType {
35     kAutoConnectTypeDisabled = 0,
36     kAutoConnectTypeEnabled = 1,
37     kAutoConnectTypeUnspecified
38   };
39   enum StationType {
40     kStationTypeIBSS,
41     kStationTypeManaged,
42     kStationTypeUnknown,
43     kStationTypeDefault = kStationTypeManaged
44   };
45 
46   ProxyShillWifiClient() = default;
47   virtual ~ProxyShillWifiClient() = default;
48   virtual bool SetLogging() = 0;
49   virtual bool RemoveAllWifiEntries() = 0;
50   virtual bool ConfigureServiceByGuid(const std::string& guid,
51                                       AutoConnectType autoconnect,
52                                       const std::string& passphrase) = 0;
53   virtual bool ConfigureWifiService(const std::string& ssid,
54                                     const std::string& security,
55                                     const brillo::VariantDictionary& security_params,
56                                     bool save_credentials,
57                                     StationType station_type,
58                                     bool hidden_network,
59                                     const std::string& guid,
60                                     AutoConnectType autoconnect) = 0;
61   virtual bool ConnectToWifiNetwork(const std::string& ssid,
62                                     const std::string& security,
63                                     const brillo::VariantDictionary& security_params,
64                                     bool save_credentials,
65                                     StationType station_type,
66                                     bool hidden_network,
67                                     const std::string& guid,
68                                     AutoConnectType autoconnect,
69                                     long discovery_timeout_milliseconds,
70                                     long association_timeout_milliseconds,
71                                     long configuration_timeout_milliseconds,
72                                     long* discovery_time_milliseconds,
73                                     long* association_time_milliseconds,
74                                     long* configuration_time_milliseconds,
75                                     std::string* failure_reason) = 0;
76   virtual bool DisconnectFromWifiNetwork(const std::string& ssid,
77                                          long disconnect_timeout_milliseconds,
78                                          long* disconnect_time_milliseconds,
79                                          std::string* failure_reason) = 0;
80   virtual bool ConfigureBgScan(const std::string& interface_name,
81                                const std::string& method_name,
82                                uint16_t short_interval,
83                                uint16_t long_interval,
84                                int signal_threshold) = 0;
85   virtual bool GetActiveWifiSsids(std::vector<std::string>* ssids) = 0;
86   virtual bool WaitForServiceStates(const std::string& ssid,
87                                     const std::vector<std::string>& expected_states,
88                                     long wait_timeout_milliseconds,
89                                     std::string* final_state,
90                                     long* wait_time_milliseconds) = 0;
91   virtual bool CreateProfile(const std::string& profile_name) = 0;
92   virtual bool PushProfile(const std::string& profile_name) = 0;
93   virtual bool PopProfile(const std::string& profile_name) = 0;
94   virtual bool RemoveProfile(const std::string& profile_name) = 0;
95   virtual bool CleanProfiles() = 0;
96   virtual bool DeleteEntriesForSsid(const std::string& ssid) = 0;
97   virtual bool ListControlledWifiInterfaces(std::vector<std::string>* interface_names) = 0;
98   virtual bool Disconnect(const std::string& ssid) = 0;
99   virtual bool GetServiceOrder(std::string* service_order) = 0;
100   virtual bool SetServiceOrder(const std::string& service_order) = 0;
101   virtual bool GetServiceProperties(const std::string& ssid,
102                                     brillo::VariantDictionary* properties) = 0;
103   virtual bool SetSchedScan(bool enable) = 0;
104   virtual bool GetPropertyOnDevice(const std::string& interface_name,
105                                    const std::string& property_name,
106                                    brillo::Any* property_value) = 0;
107   virtual bool SetPropertyOnDevice(const std::string& interface_name,
108                                    const std::string& property_name,
109                                    const brillo::Any& property_value) = 0;
110   virtual bool RequestRoam(const std::string& interface_name, const std::string& bssid) = 0;
111   virtual bool SetDeviceEnabled(const std::string& interface_name, bool enable) = 0;
112   virtual bool DiscoverTdlsLink(const std::string& interface_name,
113                                 const std::string& peer_mac_address) = 0;
114   virtual bool EstablishTdlsLink(const std::string& interface_name,
115                                  const std::string& peer_mac_address) = 0;
116   virtual bool QueryTdlsLink(const std::string& interface_name,
117                              const std::string& peer_mac_address,
118                              std::string* status) = 0;
119   virtual bool AddWakePacketSource(const std::string& interface_name,
120                                    const std::string& source_ip_address) = 0;
121   virtual bool RemoveWakePacketSource(const std::string& interface_name,
122                                       const std::string& source_ip_address) = 0;
123   virtual bool RemoveAllWakePacketSources(const std::string& interface_name) = 0;
124 
125   std::string GetModeFromStationType(StationType station_type);
126 };
127 
128 #endif // PROXY_SHILL_WIFI_CLIENT_H
129