1 /*
2  * Copyright (C) 2016 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 ANDROID_WIFI_SYSTEM_INTERFACE_TOOL_H
18 #define ANDROID_WIFI_SYSTEM_INTERFACE_TOOL_H
19 
20 #include <array>
21 #include <cstdint>
22 #include <linux/if_ether.h>
23 
24 namespace android {
25 namespace wifi_system {
26 
27 class InterfaceTool {
28  public:
29   InterfaceTool() = default;
30   virtual ~InterfaceTool() = default;
31 
32   // Get the interface state of |if_name|.
33   // Returns true iff the interface is up.
34   virtual bool GetUpState(const char* if_name);
35 
36   // Set the interface named by |if_name| up or down.
37   // Returns true on success, false otherwise.
38   virtual bool SetUpState(const char* if_name, bool request_up);
39 
40   // A helpful alias for SetUpState() that assumes there is a single system
41   // WiFi interface.  Prefer this form if you're hardcoding "wlan0" to help us
42   // identify all the places we are hardcoding the name of the wifi interface.
43   virtual bool SetWifiUpState(bool request_up);
44 
45   // Set the MAC address of the |if_name| interface
46   // Returns true on success, false otherwise.
47   virtual bool SetMacAddress(const char* if_name,
48                              const std::array<uint8_t, ETH_ALEN>& address);
49 };  // class InterfaceTool
50 
51 }  // namespace wifi_system
52 }  // namespace android
53 
54 #endif  // ANDROID_WIFI_SYSTEM_INTERFACE_TOOL_H
55