OSDN Git Service

Add support for creating client interfaces
[android-x86/system-connectivity-wificond.git] / server.h
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 WIFICOND_SERVER_H_
18 #define WIFICOND_SERVER_H_
19
20 #include <memory>
21 #include <string>
22 #include <vector>
23
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>
28
29 #include "android/net/wifi/BnWificond.h"
30 #include "android/net/wifi/IApInterface.h"
31 #include "android/net/wifi/IClientInterface.h"
32
33 #include "wificond/ap_interface_impl.h"
34 #include "wificond/client_interface_impl.h"
35
36 namespace android {
37 namespace wificond {
38
39 class NL80211Packet;
40 class NetlinkManager;
41
42 class Server : public android::net::wifi::BnWificond {
43  public:
44   Server(std::unique_ptr<wifi_system::HalTool> hal_tool,
45          std::unique_ptr<wifi_system::InterfaceTool> if_tool,
46          std::unique_ptr<wifi_hal::DriverTool> driver_tool,
47          NetlinkManager* netlink_manager);
48   ~Server() override = default;
49
50   android::binder::Status createApInterface(
51       android::sp<android::net::wifi::IApInterface>*
52           created_interface) override;
53
54   android::binder::Status createClientInterface(
55       android::sp<android::net::wifi::IClientInterface>*
56           created_interface) override;
57
58   android::binder::Status tearDownInterfaces() override;
59
60  private:
61   // Does the actual work of setting up an interface for a particular mode.
62   //
63   // |mode| is one of WIFI_GET_FW_PATH_* defined in hardware_legacy/wifi.h.
64   // |interface_name| is a pointer to a string to store the name of Linux
65   //     network interface that has been setup.
66   //
67   // Returns true on success, false otherwise.
68   bool SetupInterfaceForMode(int mode, std::string* interface_name);
69   bool RefreshWiphyIndex();
70
71   const std::unique_ptr<wifi_system::HalTool> hal_tool_;
72   const std::unique_ptr<wifi_system::InterfaceTool> if_tool_;
73   const std::unique_ptr<wifi_hal::DriverTool> driver_tool_;
74   NetlinkManager* netlink_manager_;
75
76   uint32_t wiphy_index_;
77   std::vector<std::unique_ptr<ApInterfaceImpl>> ap_interfaces_;
78   std::vector<std::unique_ptr<ClientInterfaceImpl>> client_interfaces_;
79
80   DISALLOW_COPY_AND_ASSIGN(Server);
81 };
82
83 }  // namespace wificond
84 }  // namespace android
85
86 #endif  // WIFICOND_SERVER_H_