diff options
author | Ningyuan Wang | 2016-08-11 11:59:22 -0500 |
---|---|---|
committer | Ningyuan Wang | 2016-08-12 16:17:59 -0500 |
commit | 9bc59a058868140e33bc7c46c9232c8d9b9148ca (patch) | |
tree | 7d6d21267bc0bc4e298d3e2aec1fc7201ffcb04a /server.cpp | |
parent | 8c8faa2a8999e5ecbe5b05605946ad66a7a202a4 (diff) | |
download | system-connectivity-wificond-9bc59a058868140e33bc7c46c9232c8d9b9148ca.tar.gz system-connectivity-wificond-9bc59a058868140e33bc7c46c9232c8d9b9148ca.tar.xz system-connectivity-wificond-9bc59a058868140e33bc7c46c9232c8d9b9148ca.zip |
Get interface index from kernel for wificond
This CL adds the interface index query to interface name query.
With interface index wificond can assign scan request to specific
interface and ignore scan result from uninteresting interfaces.
BUG=30808053
TEST=compile, unit tests, integration tests
Change-Id: I2a6333dcad4e9faadb7793501762602017125865
Diffstat (limited to 'server.cpp')
-rw-r--r-- | server.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -48,12 +48,16 @@ Server::Server(unique_ptr<HalTool> hal_tool, | |||
48 | 48 | ||
49 | Status Server::createApInterface(sp<IApInterface>* created_interface) { | 49 | Status Server::createApInterface(sp<IApInterface>* created_interface) { |
50 | string interface_name; | 50 | string interface_name; |
51 | if (!SetupInterfaceForMode(DriverTool::kFirmwareModeAp, &interface_name)) { | 51 | uint32_t interface_index; |
52 | if (!SetupInterfaceForMode(DriverTool::kFirmwareModeAp, | ||
53 | &interface_name, | ||
54 | &interface_index)) { | ||
52 | return Status::ok(); // Logging was done internally | 55 | return Status::ok(); // Logging was done internally |
53 | } | 56 | } |
54 | 57 | ||
55 | unique_ptr<ApInterfaceImpl> ap_interface(new ApInterfaceImpl( | 58 | unique_ptr<ApInterfaceImpl> ap_interface(new ApInterfaceImpl( |
56 | interface_name, | 59 | interface_name, |
60 | interface_index, | ||
57 | unique_ptr<HostapdManager>(new HostapdManager))); | 61 | unique_ptr<HostapdManager>(new HostapdManager))); |
58 | *created_interface = ap_interface->GetBinder(); | 62 | *created_interface = ap_interface->GetBinder(); |
59 | ap_interfaces_.push_back(std::move(ap_interface)); | 63 | ap_interfaces_.push_back(std::move(ap_interface)); |
@@ -62,13 +66,16 @@ Status Server::createApInterface(sp<IApInterface>* created_interface) { | |||
62 | 66 | ||
63 | Status Server::createClientInterface(sp<IClientInterface>* created_interface) { | 67 | Status Server::createClientInterface(sp<IClientInterface>* created_interface) { |
64 | string interface_name; | 68 | string interface_name; |
69 | uint32_t interface_index; | ||
65 | if (!SetupInterfaceForMode(DriverTool::kFirmwareModeSta, | 70 | if (!SetupInterfaceForMode(DriverTool::kFirmwareModeSta, |
66 | &interface_name)) { | 71 | &interface_name, |
72 | &interface_index)) { | ||
67 | return Status::ok(); // Logging was done internally | 73 | return Status::ok(); // Logging was done internally |
68 | } | 74 | } |
69 | 75 | ||
70 | unique_ptr<ClientInterfaceImpl> client_interface(new ClientInterfaceImpl( | 76 | unique_ptr<ClientInterfaceImpl> client_interface(new ClientInterfaceImpl( |
71 | interface_name)); | 77 | interface_name, |
78 | interface_index)); | ||
72 | *created_interface = client_interface->GetBinder(); | 79 | *created_interface = client_interface->GetBinder(); |
73 | client_interfaces_.push_back(std::move(client_interface)); | 80 | client_interfaces_.push_back(std::move(client_interface)); |
74 | return Status::ok(); | 81 | return Status::ok(); |
@@ -83,7 +90,9 @@ Status Server::tearDownInterfaces() { | |||
83 | return Status::ok(); | 90 | return Status::ok(); |
84 | } | 91 | } |
85 | 92 | ||
86 | bool Server::SetupInterfaceForMode(int mode, string* interface_name) { | 93 | bool Server::SetupInterfaceForMode(int mode, |
94 | string* interface_name, | ||
95 | uint32_t* interface_index) { | ||
87 | if (!ap_interfaces_.empty() || !client_interfaces_.empty()) { | 96 | if (!ap_interfaces_.empty() || !client_interfaces_.empty()) { |
88 | // In the future we may support multiple interfaces at once. However, | 97 | // In the future we may support multiple interfaces at once. However, |
89 | // today, we support just one. | 98 | // today, we support just one. |
@@ -105,7 +114,9 @@ bool Server::SetupInterfaceForMode(int mode, string* interface_name) { | |||
105 | return false; | 114 | return false; |
106 | } | 115 | } |
107 | 116 | ||
108 | if (!netlink_utils_->GetInterfaceName(wiphy_index_, interface_name)) { | 117 | if (!netlink_utils_->GetInterfaceNameAndIndex(wiphy_index_, |
118 | interface_name, | ||
119 | interface_index)) { | ||
109 | return false; | 120 | return false; |
110 | } | 121 | } |
111 | 122 | ||