2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef WIFICOND_SERVER_H_
18 #define WIFICOND_SERVER_H_
24 #include <android-base/macros.h>
25 #include <wifi_hal/driver_tool.h>
26 #include <wifi_system/hal_tool.h>
27 #include <wifi_system/interface_tool.h>
29 #include "android/net/wifi/BnWificond.h"
30 #include "android/net/wifi/IApInterface.h"
31 #include "android/net/wifi/IClientInterface.h"
33 #include "wificond/ap_interface_impl.h"
34 #include "wificond/client_interface_impl.h"
43 class Server : public android::net::wifi::BnWificond {
45 Server(std::unique_ptr<wifi_system::HalTool> hal_tool,
46 std::unique_ptr<wifi_system::InterfaceTool> if_tool,
47 std::unique_ptr<wifi_hal::DriverTool> driver_tool,
48 std::unique_ptr<wifi_system::SupplicantManager> supplicant_man,
49 std::unique_ptr<wifi_system::HostapdManager> hostapd_man,
50 NetlinkUtils* netlink_utils,
51 ScanUtils* scan_utils);
52 ~Server() override = default;
54 android::binder::Status createApInterface(
55 android::sp<android::net::wifi::IApInterface>*
56 created_interface) override;
58 android::binder::Status createClientInterface(
59 android::sp<android::net::wifi::IClientInterface>*
60 created_interface) override;
62 android::binder::Status tearDownInterfaces() override;
64 // Call this once on startup. It ignores all the invariants held
65 // in wificond and tries to restore ourselves to a blank state by
66 // killing userspace daemons and cleaning up the interface state.
67 void CleanUpSystemState();
70 // Does the actual work of setting up an interface for a particular mode.
72 // |mode| is one of WIFI_GET_FW_PATH_* defined in hardware_legacy/wifi.h.
73 // |interface_name| is a pointer to a string to store the name of Linux
74 // network interface that has been setup.
76 // Returns true on success, false otherwise.
77 bool SetupInterfaceForMode(int mode,
78 std::string* interface_name,
79 uint32_t* interface_index,
80 std::vector<uint8_t>* interface_mac_addr);
81 bool RefreshWiphyIndex();
83 const std::unique_ptr<wifi_system::HalTool> hal_tool_;
84 const std::unique_ptr<wifi_system::InterfaceTool> if_tool_;
85 const std::unique_ptr<wifi_hal::DriverTool> driver_tool_;
86 const std::unique_ptr<wifi_system::SupplicantManager> supplicant_manager_;
87 const std::unique_ptr<wifi_system::HostapdManager> hostapd_manager_;
88 NetlinkUtils* const netlink_utils_;
89 ScanUtils* const scan_utils_;
91 uint32_t wiphy_index_;
92 std::vector<std::unique_ptr<ApInterfaceImpl>> ap_interfaces_;
93 std::vector<std::unique_ptr<ClientInterfaceImpl>> client_interfaces_;
95 DISALLOW_COPY_AND_ASSIGN(Server);
98 } // namespace wificond
99 } // namespace android
101 #endif // WIFICOND_SERVER_H_