diff options
author | Christopher Wiley | 2016-07-27 15:48:22 -0500 |
---|---|---|
committer | Christopher Wiley | 2016-08-02 17:53:31 -0500 |
commit | c139fbf821d3c62523afbcf0950ebc2d1abaa93d (patch) | |
tree | 1b195b2e620bd77bb396faa2771ad4e9d7e53064 /server.cpp | |
parent | 2acbc1243c156aa13c54fcc4723a79f398da47ec (diff) | |
download | system-connectivity-wificond-c139fbf821d3c62523afbcf0950ebc2d1abaa93d.tar.gz system-connectivity-wificond-c139fbf821d3c62523afbcf0950ebc2d1abaa93d.tar.xz system-connectivity-wificond-c139fbf821d3c62523afbcf0950ebc2d1abaa93d.zip |
Add support for creating client interfaces
Bug: 30041062
Test: unit/integration tests pass
Change-Id: I48a0adc338e474085c399750441198a4acae2cf5
Diffstat (limited to 'server.cpp')
-rw-r--r-- | server.cpp | 39 |
1 files changed, 26 insertions, 13 deletions
@@ -27,6 +27,7 @@ using std::string; | |||
27 | using std::vector; | 27 | using std::vector; |
28 | using std::unique_ptr; | 28 | using std::unique_ptr; |
29 | using android::net::wifi::IApInterface; | 29 | using android::net::wifi::IApInterface; |
30 | using android::net::wifi::IClientInterface; | ||
30 | using android::wifi_hal::DriverTool; | 31 | using android::wifi_hal::DriverTool; |
31 | using android::wifi_system::HalTool; | 32 | using android::wifi_system::HalTool; |
32 | using android::wifi_system::HostapdManager; | 33 | using android::wifi_system::HostapdManager; |
@@ -46,13 +47,6 @@ Server::Server(unique_ptr<HalTool> hal_tool, | |||
46 | } | 47 | } |
47 | 48 | ||
48 | Status Server::createApInterface(sp<IApInterface>* created_interface) { | 49 | Status Server::createApInterface(sp<IApInterface>* created_interface) { |
49 | if (!ap_interfaces_.empty()) { | ||
50 | // In the future we may support multiple interfaces at once. However, | ||
51 | // today, we support just one. | ||
52 | LOG(ERROR) << "Cannot create AP interface when other interfaces exist"; | ||
53 | return Status::ok(); | ||
54 | } | ||
55 | |||
56 | string interface_name; | 50 | string interface_name; |
57 | if (!SetupInterfaceForMode(DriverTool::kFirmwareModeAp, &interface_name)) { | 51 | if (!SetupInterfaceForMode(DriverTool::kFirmwareModeAp, &interface_name)) { |
58 | return Status::ok(); // Logging was done internally | 52 | return Status::ok(); // Logging was done internally |
@@ -66,18 +60,37 @@ Status Server::createApInterface(sp<IApInterface>* created_interface) { | |||
66 | return Status::ok(); | 60 | return Status::ok(); |
67 | } | 61 | } |
68 | 62 | ||
63 | Status Server::createClientInterface(sp<IClientInterface>* created_interface) { | ||
64 | string interface_name; | ||
65 | if (!SetupInterfaceForMode(DriverTool::kFirmwareModeSta, | ||
66 | &interface_name)) { | ||
67 | return Status::ok(); // Logging was done internally | ||
68 | } | ||
69 | |||
70 | unique_ptr<ClientInterfaceImpl> client_interface(new ClientInterfaceImpl( | ||
71 | interface_name)); | ||
72 | *created_interface = client_interface->GetBinder(); | ||
73 | client_interfaces_.push_back(std::move(client_interface)); | ||
74 | return Status::ok(); | ||
75 | } | ||
76 | |||
69 | Status Server::tearDownInterfaces() { | 77 | Status Server::tearDownInterfaces() { |
70 | if (!ap_interfaces_.empty()) { | 78 | ap_interfaces_.clear(); |
71 | ap_interfaces_.clear(); | 79 | client_interfaces_.clear(); |
72 | if (!driver_tool_->UnloadDriver()) { | 80 | if (!driver_tool_->UnloadDriver()) { |
73 | LOG(ERROR) << "Failed to unload WiFi driver!"; | 81 | LOG(ERROR) << "Failed to unload WiFi driver!"; |
74 | return Status::ok(); | ||
75 | } | ||
76 | } | 82 | } |
77 | return Status::ok(); | 83 | return Status::ok(); |
78 | } | 84 | } |
79 | 85 | ||
80 | bool Server::SetupInterfaceForMode(int mode, string* interface_name) { | 86 | bool Server::SetupInterfaceForMode(int mode, string* interface_name) { |
87 | if (!ap_interfaces_.empty() || !client_interfaces_.empty()) { | ||
88 | // In the future we may support multiple interfaces at once. However, | ||
89 | // today, we support just one. | ||
90 | LOG(ERROR) << "Cannot create AP interface when other interfaces exist"; | ||
91 | return false; | ||
92 | } | ||
93 | |||
81 | string result; | 94 | string result; |
82 | if (!driver_tool_->LoadDriver()) { | 95 | if (!driver_tool_->LoadDriver()) { |
83 | LOG(ERROR) << "Failed to load WiFi driver!"; | 96 | LOG(ERROR) << "Failed to load WiFi driver!"; |