diff options
author | Roshan Pius <rpius@google.com> | 2017-03-16 09:37:24 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-03-17 17:33:49 -0700 |
commit | 9c0c8f38f6d320c96d52f09d51a98937aab089aa (patch) | |
tree | 20d57c8c120d7ddad1181e2f8fbea9f0dae2d3b6 | |
parent | 235f7da827f7236c90f837b5604a026d3f61b8a1 (diff) | |
download | wpa_supplicant_8-9c0c8f38f6d320c96d52f09d51a98937aab089aa.tar.gz |
wpa_supplicant(hidl): Support for P2P client list and save config
Bug: 36042785
Test: Compiles
Change-Id: Id171e4965fb096ddb312881e48039c92103c509f
-rw-r--r-- | wpa_supplicant/hidl/p2p_iface.cpp | 19 | ||||
-rw-r--r-- | wpa_supplicant/hidl/p2p_iface.h | 2 | ||||
-rw-r--r-- | wpa_supplicant/hidl/p2p_network.cpp | 56 | ||||
-rw-r--r-- | wpa_supplicant/hidl/p2p_network.h | 8 |
4 files changed, 85 insertions, 0 deletions
diff --git a/wpa_supplicant/hidl/p2p_iface.cpp b/wpa_supplicant/hidl/p2p_iface.cpp index 86f6f8ff..ce9aaf71 100644 --- a/wpa_supplicant/hidl/p2p_iface.cpp +++ b/wpa_supplicant/hidl/p2p_iface.cpp @@ -495,6 +495,13 @@ Return<void> P2pIface::reportNfcHandoverInitiation( &P2pIface::reportNfcHandoverInitiationInternal, _hidl_cb, select); } +Return<void> P2pIface::saveConfig(saveConfig_cb _hidl_cb) +{ + return validateAndCall( + this, SupplicantStatusCode::FAILURE_IFACE_INVALID, + &P2pIface::saveConfigInternal, _hidl_cb); +} + std::pair<SupplicantStatus, std::string> P2pIface::getNameInternal() { return {{SupplicantStatusCode::SUCCESS, ""}, ifname_}; @@ -1207,6 +1214,18 @@ SupplicantStatus P2pIface::reportNfcHandoverInitiationInternal( return {SupplicantStatusCode::SUCCESS, ""}; } +SupplicantStatus P2pIface::saveConfigInternal() +{ + struct wpa_supplicant* wpa_s = retrieveIfacePtr(); + if (!wpa_s->conf->update_config) { + return {SupplicantStatusCode::FAILURE_UNKNOWN, ""}; + } + if (wpa_config_write(wpa_s->confname, wpa_s->conf)) { + return {SupplicantStatusCode::FAILURE_UNKNOWN, ""}; + } + return {SupplicantStatusCode::SUCCESS, ""}; +} + /** * Retrieve the underlying |wpa_supplicant| struct * pointer for this iface. diff --git a/wpa_supplicant/hidl/p2p_iface.h b/wpa_supplicant/hidl/p2p_iface.h index e8770c63..4f08a788 100644 --- a/wpa_supplicant/hidl/p2p_iface.h +++ b/wpa_supplicant/hidl/p2p_iface.h @@ -184,6 +184,7 @@ public: Return<void> reportNfcHandoverInitiation( const hidl_vec<uint8_t>& select, reportNfcHandoverInitiation_cb _hidl_cb) override; + Return<void> saveConfig(saveConfig_cb _hidl_cb) override; private: // Corresponding worker functions for the HIDL methods. @@ -287,6 +288,7 @@ private: const std::vector<uint8_t>& request); SupplicantStatus reportNfcHandoverInitiationInternal( const std::vector<uint8_t>& select); + SupplicantStatus saveConfigInternal(); struct wpa_supplicant* retrieveIfacePtr(); struct wpa_supplicant* retrieveGroupIfacePtr( diff --git a/wpa_supplicant/hidl/p2p_network.cpp b/wpa_supplicant/hidl/p2p_network.cpp index 788f99ce..7daa4539 100644 --- a/wpa_supplicant/hidl/p2p_network.cpp +++ b/wpa_supplicant/hidl/p2p_network.cpp @@ -103,6 +103,21 @@ Return<void> P2pNetwork::isGo(isGo_cb _hidl_cb) &P2pNetwork::isGoInternal, _hidl_cb); } +Return<void> P2pNetwork::setClientList( + const hidl_vec<hidl_array<uint8_t, 6>> &clients, setClientList_cb _hidl_cb) +{ + return validateAndCall( + this, SupplicantStatusCode::FAILURE_NETWORK_INVALID, + &P2pNetwork::setClientListInternal, _hidl_cb, clients); +} + +Return<void> P2pNetwork::getClientList(getClientList_cb _hidl_cb) +{ + return validateAndCall( + this, SupplicantStatusCode::FAILURE_NETWORK_INVALID, + &P2pNetwork::getClientListInternal, _hidl_cb); +} + std::pair<SupplicantStatus, uint32_t> P2pNetwork::getIdInternal() { return {{SupplicantStatusCode::SUCCESS, ""}, network_id_}; @@ -169,6 +184,47 @@ std::pair<SupplicantStatus, bool> P2pNetwork::isGoInternal() (wpa_ssid->mode == wpa_ssid::wpas_mode::WPAS_MODE_P2P_GO)}; } +SupplicantStatus P2pNetwork::setClientListInternal( + const std::vector<hidl_array<uint8_t, 6>> &clients) +{ + struct wpa_ssid *wpa_ssid = retrieveNetworkPtr(); + os_free(wpa_ssid->p2p_client_list); + // Internal representation uses a generic MAC addr/mask storage format + // (even though the mask is always 0xFF'ed for p2p_client_list). So, the + // first 6 bytes holds the client MAC address and the next 6 bytes are + // OxFF'ed. + wpa_ssid->p2p_client_list = + (u8 *)os_malloc(ETH_ALEN * 2 * clients.size()); + if (!wpa_ssid->p2p_client_list) { + return {SupplicantStatusCode::FAILURE_UNKNOWN, ""}; + } + u8 *list = wpa_ssid->p2p_client_list; + for (const auto &client : clients) { + os_memcpy(list, client.data(), ETH_ALEN); + list += ETH_ALEN; + os_memset(list, 0xFF, ETH_ALEN); + list += ETH_ALEN; + } + wpa_ssid->num_p2p_clients = clients.size(); + return {SupplicantStatusCode::SUCCESS, ""}; +} + +std::pair<SupplicantStatus, std::vector<hidl_array<uint8_t, 6>>> +P2pNetwork::getClientListInternal() +{ + struct wpa_ssid *wpa_ssid = retrieveNetworkPtr(); + if (!wpa_ssid->p2p_client_list) { + return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, {}}; + } + std::vector<hidl_array<uint8_t, 6>> clients; + u8 *list = wpa_ssid->p2p_client_list; + for (size_t i = 0; i < wpa_ssid->num_p2p_clients; i++) { + clients.emplace_back(list); + list += 2 * ETH_ALEN; + } + return {{SupplicantStatusCode::SUCCESS, ""}, clients}; +} + /** * Retrieve the underlying |wpa_ssid| struct pointer for * this network. diff --git a/wpa_supplicant/hidl/p2p_network.h b/wpa_supplicant/hidl/p2p_network.h index d09a6be1..6164f430 100644 --- a/wpa_supplicant/hidl/p2p_network.h +++ b/wpa_supplicant/hidl/p2p_network.h @@ -55,6 +55,10 @@ public: Return<void> isCurrent(isCurrent_cb _hidl_cb) override; Return<void> isPersistent(isPersistent_cb _hidl_cb) override; Return<void> isGo(isGo_cb _hidl_cb) override; + Return<void> setClientList( + const hidl_vec<hidl_array<uint8_t, 6>>& clients, + setClientList_cb _hidl_cb) override; + Return<void> getClientList(getClientList_cb _hidl_cb) override; private: // Corresponding worker functions for the HIDL methods. @@ -68,6 +72,10 @@ private: std::pair<SupplicantStatus, bool> isCurrentInternal(); std::pair<SupplicantStatus, bool> isPersistentInternal(); std::pair<SupplicantStatus, bool> isGoInternal(); + SupplicantStatus setClientListInternal( + const std::vector<hidl_array<uint8_t, 6>>& clients); + std::pair<SupplicantStatus, std::vector<hidl_array<uint8_t, 6>>> + getClientListInternal(); struct wpa_ssid* retrieveNetworkPtr(); struct wpa_supplicant* retrieveIfacePtr(); |