wpa_supplicant: HIDL implementation (2/2)
Migrated the AIDL interface to HIDL.
Summary of the changes:
1. Changed method signatures to always invoke a callback with the
status of the operation and possibly a return value.
2. Use hidl_vec, hidl_string, hidl_array in place of
std::vector, std::string, normal array, for all HIDL method params.
3. Removed all parcelables and instead use the structs declared in the
HIDL interface.
4. Moved all constants to enums and use static_cast to retrieve their
underlying values.
5. Changed the input params for |ISupplicant.createInterface|. Only the
interface name is passed by the caller, the rest of the params are
hardcoded in the implementation of the HIDL interface.
6. Changed any remaining comments from "C" style to "C++" style.
7. Move the implementation to
android::hardware::wifi:supplicant::V1_0::implementation namespace.
TODO's:
1. Need to handle the |notifyNetworkRequest|. This needs some
additional string parsing logic which will be handled in a future CL.
2. Death notifications are not yet added in the HIDL interface. So, that
part of the code is under "#if 0".
3. The |hidl_vec| implementation does not support an |assign| method
yet, so marked places where we need this for cleanup later.
Bug: 31365276
Test: mmm -j32 external/wpa_supplicant_8
Test: Will test on device using go/aog/279621 once the HIDL changes are
in AOSP.
Change-Id: Iff20fb3c6fc23b0122c0c07529171e3a473b1d63
diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk
index 1c69a9f..e52ff14 100644
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
@@ -1598,7 +1598,7 @@
LOCAL_SHARED_LIBRARIES += libdbus
endif
ifeq ($(WPA_SUPPLICANT_USE_HIDL), y)
-LOCAL_SHARED_LIBRARIES += android.hardware.wifi@1.0
+LOCAL_SHARED_LIBRARIES += android.hardware.wifi.supplicant@1.0
LOCAL_SHARED_LIBRARIES += libhidl libhwbinder libutils
LOCAL_STATIC_LIBRARIES += libwpa_hidl
endif
@@ -1657,7 +1657,7 @@
hidl/network.cpp \
hidl/supplicant.cpp
LOCAL_SHARED_LIBRARIES := \
- android.hardware.wifi@1.0 \
+ android.hardware.wifi.supplicant@1.0 \
libhidl \
libhwbinder \
libutils
diff --git a/wpa_supplicant/hidl/hidl.cpp b/wpa_supplicant/hidl/hidl.cpp
index 258fa2b..599938d 100644
--- a/wpa_supplicant/hidl/hidl.cpp
+++ b/wpa_supplicant/hidl/hidl.cpp
@@ -7,9 +7,8 @@
* See README for more details.
*/
-#include <hidl/IPCThreadState.h>
-#include <hidl/IServiceManager.h>
-#include <hidl/ProcessState.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
#include "hidl_manager.h"
@@ -21,19 +20,22 @@
#include "utils/includes.h"
}
+using android::hardware::ProcessState;
+using android::hardware::IPCThreadState;
+using android::hardware::wifi::supplicant::V1_0::implementation::HidlManager;
+
void wpas_hidl_sock_handler(
int /* sock */, void * /* eloop_ctx */, void *sock_ctx)
{
struct wpas_hidl_priv *priv = (wpas_hidl_priv *)sock_ctx;
- wpa_printf(
- MSG_DEBUG, "Processing hidl events on FD %d", priv->hidl_fd);
- android::IPCThreadState::self()->handlePolledCommands();
+ wpa_printf(MSG_DEBUG, "Processing hidl events on FD %d", priv->hidl_fd);
+ IPCThreadState::self()->handlePolledCommands();
}
struct wpas_hidl_priv *wpas_hidl_init(struct wpa_global *global)
{
struct wpas_hidl_priv *priv;
- wpa_supplicant_hidl::HidlManager *hidl_manager;
+ HidlManager *hidl_manager;
priv = (wpas_hidl_priv *)os_zalloc(sizeof(*priv));
if (!priv)
@@ -42,25 +44,24 @@
wpa_printf(MSG_DEBUG, "Initing hidl control");
- android::ProcessState::self()->setThreadPoolMaxThreadCount(0);
- android::IPCThreadState::self()->disableBackgroundScheduling(true);
- android::IPCThreadState::self()->setupPolling(&priv->hidl_fd);
+ ProcessState::self()->setThreadPoolMaxThreadCount(0);
+ IPCThreadState::self()->disableBackgroundScheduling(true);
+ IPCThreadState::self()->setupPolling(&priv->hidl_fd);
if (priv->hidl_fd < 0)
goto err;
- wpa_printf(
- MSG_INFO, "Processing hidl events on FD %d", priv->hidl_fd);
- /* Look for read events from the hidl socket in the eloop. */
+ wpa_printf(MSG_INFO, "Processing hidl events on FD %d", priv->hidl_fd);
+ // Look for read events from the hidl socket in the eloop.
if (eloop_register_read_sock(
priv->hidl_fd, wpas_hidl_sock_handler, global, priv) < 0)
goto err;
- hidl_manager = wpa_supplicant_hidl::HidlManager::getInstance();
+ hidl_manager = HidlManager::getInstance();
if (!hidl_manager)
goto err;
hidl_manager->registerHidlService(global);
- /* We may not need to store this hidl manager reference in the
- * global data strucure because we've made it a singleton class. */
+ // We may not need to store this hidl manager reference in the
+ // global data strucure because we've made it a singleton class.
priv->hidl_manager = (void *)hidl_manager;
return priv;
@@ -76,9 +77,9 @@
wpa_printf(MSG_DEBUG, "Deiniting hidl control");
- wpa_supplicant_hidl::HidlManager::destroyInstance();
+ HidlManager::destroyInstance();
eloop_unregister_read_sock(priv->hidl_fd);
- android::IPCThreadState::shutdown();
+ IPCThreadState::shutdown();
os_free(priv);
}
@@ -91,8 +92,7 @@
MSG_DEBUG, "Registering interface to hidl control: %s",
wpa_s->ifname);
- wpa_supplicant_hidl::HidlManager *hidl_manager =
- wpa_supplicant_hidl::HidlManager::getInstance();
+ HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager)
return 1;
@@ -108,8 +108,7 @@
MSG_DEBUG, "Deregistering interface from hidl control: %s",
wpa_s->ifname);
- wpa_supplicant_hidl::HidlManager *hidl_manager =
- wpa_supplicant_hidl::HidlManager::getInstance();
+ HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager)
return 1;
@@ -125,8 +124,7 @@
wpa_printf(
MSG_DEBUG, "Registering network to hidl control: %d", ssid->id);
- wpa_supplicant_hidl::HidlManager *hidl_manager =
- wpa_supplicant_hidl::HidlManager::getInstance();
+ HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager)
return 1;
@@ -140,11 +138,9 @@
return 1;
wpa_printf(
- MSG_DEBUG, "Deregistering network from hidl control: %d",
- ssid->id);
+ MSG_DEBUG, "Deregistering network from hidl control: %d", ssid->id);
- wpa_supplicant_hidl::HidlManager *hidl_manager =
- wpa_supplicant_hidl::HidlManager::getInstance();
+ HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager)
return 1;
@@ -160,8 +156,7 @@
MSG_DEBUG, "Notifying state change event to hidl control: %d",
wpa_s->wpa_state);
- wpa_supplicant_hidl::HidlManager *hidl_manager =
- wpa_supplicant_hidl::HidlManager::getInstance();
+ HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager)
return 1;
@@ -179,8 +174,7 @@
MSG_DEBUG, "Notifying network request to hidl control: %d",
ssid->id);
- wpa_supplicant_hidl::HidlManager *hidl_manager =
- wpa_supplicant_hidl::HidlManager::getInstance();
+ HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager)
return 1;
diff --git a/wpa_supplicant/hidl/hidl.h b/wpa_supplicant/hidl/hidl.h
index 594098d..ee7cab1 100644
--- a/wpa_supplicant/hidl/hidl.h
+++ b/wpa_supplicant/hidl/hidl.h
@@ -12,7 +12,7 @@
#ifdef _cplusplus
extern "C" {
-#endif /* _cplusplus */
+#endif // _cplusplus
/**
* This is the hidl RPC interface entry point to the wpa_supplicant core.
@@ -36,7 +36,7 @@
int wpas_hidl_notify_network_request(
struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
enum wpa_ctrl_req_type rtype, const char *default_txt);
-#else /* CONFIG_CTRL_IFACE_HIDL */
+#else // CONFIG_CTRL_IFACE_HIDL
static inline int wpas_hidl_register_interface(struct wpa_supplicant *wpa_s)
{
return 0;
@@ -65,10 +65,10 @@
{
return 0;
}
-#endif /* CONFIG_CTRL_IFACE_HIDL */
+#endif // CONFIG_CTRL_IFACE_HIDL
#ifdef _cplusplus
}
-#endif /* _cplusplus */
+#endif // _cplusplus
-#endif /* WPA_SUPPLICANT_HIDL_HIDL_H */
+#endif // WPA_SUPPLICANT_HIDL_HIDL_H
diff --git a/wpa_supplicant/hidl/hidl_i.h b/wpa_supplicant/hidl/hidl_i.h
index 8c0df2e..c7a0142 100644
--- a/wpa_supplicant/hidl/hidl_i.h
+++ b/wpa_supplicant/hidl/hidl_i.h
@@ -23,6 +23,6 @@
#ifdef _cplusplus
}
-#endif /* _cplusplus */
+#endif // _cplusplus
-#endif /* HIDL_I_H */
+#endif // HIDL_I_H
diff --git a/wpa_supplicant/hidl/hidl_manager.cpp b/wpa_supplicant/hidl/hidl_manager.cpp
index 89339c5..372b221 100644
--- a/wpa_supplicant/hidl/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/hidl_manager.cpp
@@ -9,19 +9,21 @@
#include <algorithm>
-#include <hidl/IServiceManager.h>
-
-#include "hidl_constants.h"
#include "hidl_manager.h"
-#include "wpa_supplicant_hidl/hidl_constants.h"
extern "C" {
#include "utils/common.h"
#include "utils/includes.h"
}
-namespace wpa_supplicant_hidl {
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
+const char HidlManager::kServiceName[] = "wpa_supplicant";
HidlManager *HidlManager::instance_ = NULL;
HidlManager *HidlManager::getInstance()
@@ -40,13 +42,12 @@
int HidlManager::registerHidlService(struct wpa_global *global)
{
- // Create the main hidl service object and register with system
- // ServiceManager.
+ // Create the main hidl service object and register it.
supplicant_object_ = new Supplicant(global);
-
- android::String16 service_name(hidl_constants::kServiceName);
- android::defaultServiceManager()->addService(
- service_name, android::IInterface::asHidl(supplicant_object_));
+ if (supplicant_object_->registerAsService(kServiceName) !=
+ android::NO_ERROR) {
+ return 1;
+ }
return 0;
}
@@ -75,12 +76,12 @@
// Initialize the vector of callbacks for this object.
iface_callbacks_map_[ifname] =
- std::vector<android::sp<fi::w1::wpa_supplicant::IIfaceCallback>>();
+ std::vector<android::sp<ISupplicantIfaceCallback>>();
- // Invoke the |OnInterfaceCreated| method on all registered callbacks.
+ // Invoke the |onInterfaceCreated| method on all registered callbacks.
callWithEachSupplicantCallback(std::bind(
- &fi::w1::wpa_supplicant::ISupplicantCallback::OnInterfaceCreated,
- std::placeholders::_1, ifname));
+ &ISupplicantCallback::onInterfaceCreated, std::placeholders::_1,
+ ifname));
return 0;
}
@@ -109,21 +110,24 @@
if (iface_callback_map_iter == iface_callbacks_map_.end())
return 1;
const auto &iface_callback_list = iface_callback_map_iter->second;
+#if 0 // TODO(b/31632518): HIDL object death notifications.
for (const auto &callback : iface_callback_list) {
- if (android::IInterface::asHidl(callback)->unlinkToDeath(
- nullptr, callback.get()) != android::OK) {
+ if (android::hardware::IInterface::asBinder(callback)
+ ->unlinkToDeath(nullptr, callback.get()) !=
+ android::OK) {
wpa_printf(
MSG_ERROR,
"Error deregistering for death notification for "
"iface callback object");
}
}
+#endif // TODO(b/31632518): HIDL object death notifications.
iface_callbacks_map_.erase(iface_callback_map_iter);
- // Invoke the |OnInterfaceRemoved| method on all registered callbacks.
+ // Invoke the |onInterfaceRemoved| method on all registered callbacks.
callWithEachSupplicantCallback(std::bind(
- &fi::w1::wpa_supplicant::ISupplicantCallback::OnInterfaceRemoved,
- std::placeholders::_1, ifname));
+ &ISupplicantCallback::onInterfaceRemoved, std::placeholders::_1,
+ ifname));
return 0;
}
@@ -155,15 +159,14 @@
return 1;
// Initialize the vector of callbacks for this object.
- network_callbacks_map_[network_key] = std::vector<
- android::sp<fi::w1::wpa_supplicant::INetworkCallback>>();
+ network_callbacks_map_[network_key] =
+ std::vector<android::sp<ISupplicantNetworkCallback>>();
- // Invoke the |OnNetworkAdded| method on all registered callbacks.
+ // Invoke the |onNetworkAdded| method on all registered callbacks.
callWithEachIfaceCallback(
- wpa_s->ifname,
- std::bind(
- &fi::w1::wpa_supplicant::IIfaceCallback::OnNetworkAdded,
- std::placeholders::_1, ssid->id));
+ wpa_s->ifname, std::bind(
+ &ISupplicantIfaceCallback::onNetworkAdded,
+ std::placeholders::_1, ssid->id));
return 0;
}
@@ -198,9 +201,11 @@
if (network_callback_map_iter == network_callbacks_map_.end())
return 1;
const auto &network_callback_list = network_callback_map_iter->second;
+#if 0 // TODO(b/31632518): HIDL object death notifications.
for (const auto &callback : network_callback_list) {
- if (android::IInterface::asHidl(callback)->unlinkToDeath(
- nullptr, callback.get()) != android::OK) {
+ if (android::hardware::IInterface::asBinder(callback)
+ ->unlinkToDeath(nullptr, callback.get()) !=
+ android::OK) {
wpa_printf(
MSG_ERROR,
"Error deregistering for death "
@@ -208,14 +213,14 @@
"network callback object");
}
}
+#endif // TODO(b/31632518): HIDL object death notifications.
network_callbacks_map_.erase(network_callback_map_iter);
- // Invoke the |OnNetworkRemoved| method on all registered callbacks.
+ // Invoke the |onNetworkRemoved| method on all registered callbacks.
callWithEachIfaceCallback(
- wpa_s->ifname,
- std::bind(
- &fi::w1::wpa_supplicant::IIfaceCallback::OnNetworkRemoved,
- std::placeholders::_1, ssid->id));
+ wpa_s->ifname, std::bind(
+ &ISupplicantIfaceCallback::onNetworkRemoved,
+ std::placeholders::_1, ssid->id));
return 0;
}
@@ -234,23 +239,24 @@
if (iface_object_map_.find(ifname) == iface_object_map_.end())
return 1;
- // Invoke the |OnStateChanged| method on all registered callbacks.
- int state = wpa_s->wpa_state;
- std::vector<uint8_t> bssid(wpa_s->bssid, wpa_s->bssid + ETH_ALEN);
- int network_id =
- fi::w1::wpa_supplicant::IIfaceCallback::NETWORK_ID_INVALID;
- std::vector<uint8_t> ssid;
+ // Invoke the |onStateChanged| method on all registered callbacks.
+ ISupplicantIfaceCallback::State hidl_state =
+ static_cast<ISupplicantIfaceCallback::State>(wpa_s->wpa_state);
+ hidl_array<uint8_t, 6> hidl_bssid;
+ os_memcpy(hidl_bssid.data(), wpa_s->bssid, ETH_ALEN);
+ uint32_t hidl_network_id = UINT32_MAX;
+ std::vector<uint8_t> hidl_ssid;
if (wpa_s->current_ssid) {
- network_id = wpa_s->current_ssid->id;
- ssid.assign(
+ hidl_network_id = wpa_s->current_ssid->id;
+ hidl_ssid.assign(
wpa_s->current_ssid->ssid,
wpa_s->current_ssid->ssid + wpa_s->current_ssid->ssid_len);
}
callWithEachIfaceCallback(
- wpa_s->ifname,
- std::bind(
- &fi::w1::wpa_supplicant::IIfaceCallback::OnStateChanged,
- std::placeholders::_1, state, bssid, network_id, ssid));
+ wpa_s->ifname, std::bind(
+ &ISupplicantIfaceCallback::onStateChanged,
+ std::placeholders::_1, hidl_state, hidl_bssid,
+ hidl_network_id, hidl_ssid));
return 0;
}
@@ -275,16 +281,13 @@
if (network_object_map_.find(network_key) == network_object_map_.end())
return 1;
- callWithEachNetworkCallback(
- wpa_s->ifname, ssid->id,
- std::bind(
- &fi::w1::wpa_supplicant::INetworkCallback::OnNetworkRequest,
- std::placeholders::_1, type, param));
+ // TODO(b/31646740): Parse the param string to find the appropriate
+ // callback.
return 0;
}
/**
- * Retrieve the |IIface| hidl object reference using the provided
+ * Retrieve the |ISupplicantIface| hidl object reference using the provided
* ifname.
*
* @param ifname Name of the corresponding interface.
@@ -293,8 +296,7 @@
* @return 0 on success, 1 on failure.
*/
int HidlManager::getIfaceHidlObjectByIfname(
- const std::string &ifname,
- android::sp<fi::w1::wpa_supplicant::IIface> *iface_object)
+ const std::string &ifname, android::sp<ISupplicantIface> *iface_object)
{
if (ifname.empty() || !iface_object)
return 1;
@@ -308,7 +310,7 @@
}
/**
- * Retrieve the |INetwork| hidl object reference using the provided
+ * Retrieve the |ISupplicantNetwork| hidl object reference using the provided
* ifname and network_id.
*
* @param ifname Name of the corresponding interface.
@@ -319,7 +321,7 @@
*/
int HidlManager::getNetworkHidlObjectByIfnameAndNetworkId(
const std::string &ifname, int network_id,
- android::sp<fi::w1::wpa_supplicant::INetwork> *network_object)
+ android::sp<ISupplicantNetwork> *network_object)
{
if (ifname.empty() || network_id < 0 || !network_object)
return 1;
@@ -345,28 +347,28 @@
* @return 0 on success, 1 on failure.
*/
int HidlManager::addSupplicantCallbackHidlObject(
- const android::sp<fi::w1::wpa_supplicant::ISupplicantCallback> &callback)
+ const android::sp<ISupplicantCallback> &callback)
{
// Register for death notification before we add it to our list.
auto on_hidl_died_fctor = std::bind(
&HidlManager::removeSupplicantCallbackHidlObject, this,
std::placeholders::_1);
return registerForDeathAndAddCallbackHidlObjectToList<
- fi::w1::wpa_supplicant::ISupplicantCallback>(
+ ISupplicantCallback>(
callback, on_hidl_died_fctor, supplicant_callbacks_);
}
/**
- * Add a new |IIfaceCallback| hidl object reference to our
+ * Add a new |ISupplicantIfaceCallback| hidl object reference to our
* interface callback list.
*
* @param ifname Name of the corresponding interface.
- * @param callback Hidl reference of the |IIfaceCallback| object.
+ * @param callback Hidl reference of the |ISupplicantIfaceCallback| object.
*
* @return 0 on success, 1 on failure.
*/
int HidlManager::addIfaceCallbackHidlObject(
const std::string &ifname,
- const android::sp<fi::w1::wpa_supplicant::IIfaceCallback> &callback)
+ const android::sp<ISupplicantIfaceCallback> &callback)
{
if (ifname.empty())
return 1;
@@ -381,23 +383,23 @@
&HidlManager::removeIfaceCallbackHidlObject, this, ifname,
std::placeholders::_1);
return registerForDeathAndAddCallbackHidlObjectToList<
- fi::w1::wpa_supplicant::IIfaceCallback>(
+ ISupplicantIfaceCallback>(
callback, on_hidl_died_fctor, iface_callback_list);
}
/**
- * Add a new |INetworkCallback| hidl object reference to our
+ * Add a new |ISupplicantNetworkCallback| hidl object reference to our
* network callback list.
*
* @param ifname Name of the corresponding interface.
* @param network_id ID of the corresponding network.
- * @param callback Hidl reference of the |INetworkCallback| object.
+ * @param callback Hidl reference of the |ISupplicantNetworkCallback| object.
*
* @return 0 on success, 1 on failure.
*/
int HidlManager::addNetworkCallbackHidlObject(
const std::string &ifname, int network_id,
- const android::sp<fi::w1::wpa_supplicant::INetworkCallback> &callback)
+ const android::sp<ISupplicantNetworkCallback> &callback)
{
if (ifname.empty() || network_id < 0)
return 1;
@@ -416,13 +418,13 @@
&HidlManager::removeNetworkCallbackHidlObject, this, ifname,
network_id, std::placeholders::_1);
return registerForDeathAndAddCallbackHidlObjectToList<
- fi::w1::wpa_supplicant::INetworkCallback>(
+ ISupplicantNetworkCallback>(
callback, on_hidl_died_fctor, network_callback_list);
}
/**
* Creates a unique key for the network using the provided |ifname| and
- * |network_id| to be used in the internal map of |INetwork| objects.
+ * |network_id| to be used in the internal map of |ISupplicantNetwork| objects.
* This is of the form |ifname|_|network_id|. For ex: "wlan0_1".
*
* @param ifname Name of the corresponding interface.
@@ -441,7 +443,7 @@
* @param callback Hidl reference of the |ISupplicantCallback| object.
*/
void HidlManager::removeSupplicantCallbackHidlObject(
- const android::sp<fi::w1::wpa_supplicant::ISupplicantCallback> &callback)
+ const android::sp<ISupplicantCallback> &callback)
{
supplicant_callbacks_.erase(
std::remove(
@@ -451,15 +453,15 @@
}
/**
- * Removes the provided |IIfaceCallback| hidl object reference from
+ * Removes the provided |ISupplicantIfaceCallback| hidl object reference from
* our interface callback list.
*
* @param ifname Name of the corresponding interface.
- * @param callback Hidl reference of the |IIfaceCallback| object.
+ * @param callback Hidl reference of the |ISupplicantIfaceCallback| object.
*/
void HidlManager::removeIfaceCallbackHidlObject(
const std::string &ifname,
- const android::sp<fi::w1::wpa_supplicant::IIfaceCallback> &callback)
+ const android::sp<ISupplicantIfaceCallback> &callback)
{
if (ifname.empty())
return;
@@ -477,16 +479,16 @@
}
/**
- * Removes the provided |INetworkCallback| hidl object reference from
+ * Removes the provided |ISupplicantNetworkCallback| hidl object reference from
* our network callback list.
*
* @param ifname Name of the corresponding interface.
* @param network_id ID of the corresponding network.
- * @param callback Hidl reference of the |INetworkCallback| object.
+ * @param callback Hidl reference of the |ISupplicantNetworkCallback| object.
*/
void HidlManager::removeNetworkCallbackHidlObject(
const std::string &ifname, int network_id,
- const android::sp<fi::w1::wpa_supplicant::INetworkCallback> &callback)
+ const android::sp<ISupplicantNetworkCallback> &callback)
{
if (ifname.empty() || network_id < 0)
return;
@@ -512,7 +514,7 @@
* Add callback to the corresponding list after linking to death on the
* corresponding hidl object reference.
*
- * @param callback Hidl reference of the |INetworkCallback| object.
+ * @param callback Hidl reference of the |ISupplicantNetworkCallback| object.
*
* @return 0 on success, 1 on failure.
*/
@@ -529,10 +531,10 @@
// store a reference to this |CallbackObjectDeathNotifier| instance
// to use in |unlinkToDeath| later.
// NOTE: This may cause an immediate callback if the object is already
- // dead,
- // so add it to the list before we register for callback!
+ // dead, so add it to the list before we register for callback!
callback_list.push_back(callback);
- if (android::IInterface::asHidl(callback)->linkToDeath(
+#if 0 // TODO(b/31632518): HIDL object death notifications.
+ if (android::hardware::IInterface::asBinder(callback)->linkToDeath(
death_notifier, callback.get()) != android::OK) {
wpa_printf(
MSG_ERROR,
@@ -544,6 +546,7 @@
callback_list.end());
return 1;
}
+#endif // TODO(b/31632518): HIDL object death notifications.
return 0;
}
@@ -555,8 +558,7 @@
* |ISupplicantCallback|.
*/
void HidlManager::callWithEachSupplicantCallback(
- const std::function<android::hidl::Status(
- android::sp<fi::w1::wpa_supplicant::ISupplicantCallback>)> &method)
+ const std::function<Return<void>(android::sp<ISupplicantCallback>)> &method)
{
for (const auto &callback : supplicant_callbacks_) {
method(callback);
@@ -565,16 +567,17 @@
/**
* Helper fucntion to invoke the provided callback method on all the
- * registered |IIfaceCallback| callback hidl objects for the specified
+ * registered |ISupplicantIfaceCallback| callback hidl objects for the specified
* |ifname|.
*
* @param ifname Name of the corresponding interface.
- * @param method Pointer to the required hidl method from |IIfaceCallback|.
+ * @param method Pointer to the required hidl method from
+ * |ISupplicantIfaceCallback|.
*/
void HidlManager::callWithEachIfaceCallback(
const std::string &ifname,
- const std::function<android::hidl::Status(
- android::sp<fi::w1::wpa_supplicant::IIfaceCallback>)> &method)
+ const std::function<Return<void>(android::sp<ISupplicantIfaceCallback>)>
+ &method)
{
if (ifname.empty())
return;
@@ -590,17 +593,19 @@
/**
* Helper function to invoke the provided callback method on all the
- * registered |INetworkCallback| callback hidl objects for the specified
+ * registered |ISupplicantNetworkCallback| callback hidl objects for the
+ * specified
* |ifname| & |network_id|.
*
* @param ifname Name of the corresponding interface.
* @param network_id ID of the corresponding network.
- * @param method Pointer to the required hidl method from |INetworkCallback|.
+ * @param method Pointer to the required hidl method from
+ * |ISupplicantNetworkCallback|.
*/
void HidlManager::callWithEachNetworkCallback(
const std::string &ifname, int network_id,
- const std::function<android::hidl::Status(
- android::sp<fi::w1::wpa_supplicant::INetworkCallback>)> &method)
+ const std::function<Return<void>(android::sp<ISupplicantNetworkCallback>)>
+ &method)
{
if (ifname.empty() || network_id < 0)
return;
@@ -617,4 +622,10 @@
method(callback);
}
}
-} // namespace wpa_supplicant_hidl
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
diff --git a/wpa_supplicant/hidl/hidl_manager.h b/wpa_supplicant/hidl/hidl_manager.h
index f6178a4..f226d2d 100644
--- a/wpa_supplicant/hidl/hidl_manager.h
+++ b/wpa_supplicant/hidl/hidl_manager.h
@@ -13,9 +13,9 @@
#include <map>
#include <string>
-#include "fi/w1/wpa_supplicant/IIfaceCallback.h"
-#include "fi/w1/wpa_supplicant/INetworkCallback.h"
-#include "fi/w1/wpa_supplicant/ISupplicantCallback.h"
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantIfaceCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantNetworkCallback.h>
#include "iface.h"
#include "network.h"
@@ -24,7 +24,12 @@
struct wpa_global;
struct wpa_supplicant;
-namespace wpa_supplicant_hidl {
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
/**
* HidlManager is responsible for managing the lifetime of all
@@ -54,21 +59,26 @@
// Methods called from hidl objects.
int getIfaceHidlObjectByIfname(
const std::string &ifname,
- android::sp<fi::w1::wpa_supplicant::IIface> *iface_object);
+ android::sp<
+ android::hardware::wifi::supplicant::V1_0::ISupplicantIface>
+ *iface_object);
int getNetworkHidlObjectByIfnameAndNetworkId(
const std::string &ifname, int network_id,
- android::sp<fi::w1::wpa_supplicant::INetwork> *network_object);
+ android::sp<
+ android::hardware::wifi::supplicant::V1_0::ISupplicantNetwork>
+ *network_object);
int addSupplicantCallbackHidlObject(
- const android::sp<fi::w1::wpa_supplicant::ISupplicantCallback>
+ const android::sp<
+ android::hardware::wifi::supplicant::V1_0::ISupplicantCallback>
&callback);
int addIfaceCallbackHidlObject(
const std::string &ifname,
- const android::sp<fi::w1::wpa_supplicant::IIfaceCallback>
- &callback);
+ const android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantIfaceCallback> &callback);
int addNetworkCallbackHidlObject(
const std::string &ifname, int network_id,
- const android::sp<fi::w1::wpa_supplicant::INetworkCallback>
- &callback);
+ const android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetworkCallback> &callback);
private:
HidlManager() = default;
@@ -80,16 +90,17 @@
const std::string &ifname, int network_id);
void removeSupplicantCallbackHidlObject(
- const android::sp<fi::w1::wpa_supplicant::ISupplicantCallback>
+ const android::sp<
+ android::hardware::wifi::supplicant::V1_0::ISupplicantCallback>
&callback);
void removeIfaceCallbackHidlObject(
const std::string &ifname,
- const android::sp<fi::w1::wpa_supplicant::IIfaceCallback>
- &callback);
+ const android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantIfaceCallback> &callback);
void removeNetworkCallbackHidlObject(
const std::string &ifname, int network_id,
- const android::sp<fi::w1::wpa_supplicant::INetworkCallback>
- &callback);
+ const android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetworkCallback> &callback);
template <class CallbackType>
int registerForDeathAndAddCallbackHidlObjectToList(
const android::sp<CallbackType> &callback,
@@ -98,19 +109,22 @@
std::vector<android::sp<CallbackType>> &callback_list);
void callWithEachSupplicantCallback(
- const std::function<android::hidl::Status(
- android::sp<fi::w1::wpa_supplicant::ISupplicantCallback>)>
- &method);
+ const std::function<android::hardware::Return<void>(
+ android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantCallback>)> &method);
void callWithEachIfaceCallback(
const std::string &ifname,
- const std::function<android::hidl::Status(
- android::sp<fi::w1::wpa_supplicant::IIfaceCallback>)> &method);
+ const std::function<android::hardware::Return<void>(
+ android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantIfaceCallback>)> &method);
void callWithEachNetworkCallback(
const std::string &ifname, int network_id,
- const std::function<android::hidl::Status(
- android::sp<fi::w1::wpa_supplicant::INetworkCallback>)>
- &method);
+ const std::function<android::hardware::Return<void>(
+ android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetworkCallback>)> &method);
+ // HIDL Service name.
+ static const char kServiceName[];
// Singleton instance of this class.
static HidlManager *instance_;
// The main hidl service object.
@@ -125,33 +139,35 @@
std::map<const std::string, android::sp<Network>> network_object_map_;
// Callback registered for the main hidl service object.
- std::vector<android::sp<fi::w1::wpa_supplicant::ISupplicantCallback>>
+ std::vector<android::sp<
+ android::hardware::wifi::supplicant::V1_0::ISupplicantCallback>>
supplicant_callbacks_;
// Map of all the callbacks registered for interface specific
// hidl objects controlled by wpa_supplicant. This map is keyed in by
// the corresponding |ifname|.
std::map<
const std::string,
- std::vector<android::sp<fi::w1::wpa_supplicant::IIfaceCallback>>>
+ std::vector<android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantIfaceCallback>>>
iface_callbacks_map_;
// Map of all the callbacks registered for network specific
// hidl objects controlled by wpa_supplicant. This map is keyed in by
// the corresponding |ifname| & |network_id|.
std::map<
const std::string,
- std::vector<android::sp<fi::w1::wpa_supplicant::INetworkCallback>>>
+ std::vector<android::sp<android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetworkCallback>>>
network_callbacks_map_;
/**
* Helper class used to deregister the callback object reference from
- * our
- * callback list on the death of the hidl object.
+ * our callback list on the death of the hidl object.
* This class stores a reference of the callback hidl object and a
* function to be called to indicate the death of the hidl object.
*/
template <class CallbackType>
class CallbackObjectDeathNotifier
- : public android::IHidl::DeathRecipient
+ : public android::hardware::IBinder::DeathRecipient
{
public:
CallbackObjectDeathNotifier(
@@ -161,8 +177,8 @@
: callback_(callback), on_hidl_died_(on_hidl_died)
{
}
- void hidlDied(
- const android::wp<android::IHidl> & /* who */) override
+ void binderDied(const android::wp<android::hardware::IBinder>
+ & /* who */) override
{
on_hidl_died_(callback_);
}
@@ -180,88 +196,116 @@
// avoid nasty runtime conversion functions. So, adding compile time asserts
// to guard against any internal changes breaking the hidl interface.
static_assert(
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_NONE == WPA_KEY_MGMT_NONE,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicant::DebugLevel::EXCESSIVE) ==
+ MSG_EXCESSIVE,
+ "Debug level value mismatch");
+static_assert(
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicant::DebugLevel::ERROR) == MSG_ERROR,
+ "Debug level value mismatch");
+
+static_assert(
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::KeyMgmtMask::NONE) ==
+ WPA_KEY_MGMT_NONE,
"KeyMgmt value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_WPA_PSK == WPA_KEY_MGMT_PSK,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::KeyMgmtMask::WPA_PSK) ==
+ WPA_KEY_MGMT_PSK,
"KeyMgmt value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_WPA_EAP ==
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::KeyMgmtMask::WPA_EAP) ==
WPA_KEY_MGMT_IEEE8021X,
"KeyMgmt value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_IEEE8021X ==
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::KeyMgmtMask::IEEE8021X) ==
WPA_KEY_MGMT_IEEE8021X_NO_WPA,
"KeyMgmt value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_WPA == WPA_PROTO_WPA,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::ProtoMask::WPA) ==
+ WPA_PROTO_WPA,
"Proto value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_RSN == WPA_PROTO_RSN,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::ProtoMask::RSN) ==
+ WPA_PROTO_RSN,
"Proto value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_OSEN == WPA_PROTO_OSEN,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::ProtoMask::OSEN) ==
+ WPA_PROTO_OSEN,
"Proto value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_OPEN == WPA_AUTH_ALG_OPEN,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::AuthAlgMask::OPEN) ==
+ WPA_AUTH_ALG_OPEN,
"AuthAlg value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_SHARED ==
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::AuthAlgMask::SHARED) ==
WPA_AUTH_ALG_SHARED,
"AuthAlg value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_LEAP == WPA_AUTH_ALG_LEAP,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::AuthAlgMask::LEAP) ==
+ WPA_AUTH_ALG_LEAP,
"AuthAlg value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_WEP40 ==
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::GroupCipherMask::WEP40) ==
WPA_CIPHER_WEP40,
"GroupCipher value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_WEP104 ==
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::GroupCipherMask::WEP104) ==
WPA_CIPHER_WEP104,
"GroupCipher value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_TKIP == WPA_CIPHER_TKIP,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::GroupCipherMask::TKIP) ==
+ WPA_CIPHER_TKIP,
"GroupCipher value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_CCMP == WPA_CIPHER_CCMP,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::GroupCipherMask::CCMP) ==
+ WPA_CIPHER_CCMP,
"GroupCipher value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_NONE ==
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::PairwiseCipherMask::NONE) ==
WPA_CIPHER_NONE,
"PairwiseCipher value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_TKIP ==
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::PairwiseCipherMask::TKIP) ==
WPA_CIPHER_TKIP,
"PairwiseCipher value mismatch");
static_assert(
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_CCMP ==
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantNetwork::PairwiseCipherMask::CCMP) ==
WPA_CIPHER_CCMP,
"PairwiseCipher value mismatch");
static_assert(
- WPA_DISCONNECTED ==
- fi::w1::wpa_supplicant::IIfaceCallback::STATE_DISCONNECTED,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantIfaceCallback::State::DISCONNECTED) ==
+ WPA_DISCONNECTED,
"State value mismatch");
static_assert(
- WPA_COMPLETED == fi::w1::wpa_supplicant::IIfaceCallback::STATE_COMPLETED,
+ static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
+ ISupplicantIfaceCallback::State::COMPLETED) ==
+ WPA_COMPLETED,
"State value mismatch");
-static_assert(
- WPA_CTRL_REQ_UNKNOWN ==
- fi::w1::wpa_supplicant::INetwork::NETWORK_RSP_UNKNOWN,
- "Network Rsp value mismatch");
-static_assert(
- WPA_CTRL_REQ_EXT_CERT_CHECK ==
- fi::w1::wpa_supplicant::INetwork::NETWORK_RSP_EXT_CERT_CHECK,
- "Network Rsp value mismatch");
-static_assert(
- WPA_CTRL_REQ_UNKNOWN ==
- fi::w1::wpa_supplicant::INetworkCallback::NETWORK_REQ_UNKNOWN,
- "Network Req value mismatch");
-static_assert(
- WPA_CTRL_REQ_EXT_CERT_CHECK ==
- fi::w1::wpa_supplicant::INetworkCallback::NETWORK_REQ_EXT_CERT_CHECK,
- "Network Req value mismatch");
-} // namespace wpa_supplicant_hidl
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
#endif // WPA_SUPPLICANT_HIDL_HIDL_MANAGER_H
diff --git a/wpa_supplicant/hidl/hidl_return_macros.h b/wpa_supplicant/hidl/hidl_return_macros.h
new file mode 100644
index 0000000..25e8f49
--- /dev/null
+++ b/wpa_supplicant/hidl/hidl_return_macros.h
@@ -0,0 +1,16 @@
+/*
+ * hidl interface for wpa_supplicant daemon
+ * Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+// Macros to invoke the _hidl_cb to return status along with any return values.
+#define HIDL_RETURN(status_code, ...) \
+ do { \
+ SupplicantStatus status{.code = status_code}; \
+ _hidl_cb(status, ##__VA_ARGS__); \
+ return Void(); \
+ } while (false)
diff --git a/wpa_supplicant/hidl/iface.cpp b/wpa_supplicant/hidl/iface.cpp
index 1ba93b7..6b94aa1 100644
--- a/wpa_supplicant/hidl/iface.cpp
+++ b/wpa_supplicant/hidl/iface.cpp
@@ -8,189 +8,212 @@
*/
#include "hidl_manager.h"
+#include "hidl_return_macros.h"
#include "iface.h"
-namespace wpa_supplicant_hidl {
-
-#define RETURN_IF_IFACE_INVALID(wpa_s) \
- { \
- if (!wpa_s) { \
- return android::hidl::Status:: \
- fromServiceSpecificError( \
- ERROR_IFACE_INVALID, \
- "wpa_supplicant does not control this " \
- "interface."); \
- } \
- } // #define RETURN_IF_IFACE_INVALID(wpa_s)
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
Iface::Iface(struct wpa_global *wpa_global, const char ifname[])
: wpa_global_(wpa_global), ifname_(ifname)
{
}
-android::hidl::Status Iface::GetName(std::string *iface_name_out)
-{
- // We could directly return the name we hold, but let's verify
- // if the underlying iface still exists.
- RETURN_IF_IFACE_INVALID(retrieveIfacePtr());
- *iface_name_out = ifname_;
- return android::hidl::Status::ok();
-}
-
-android::hidl::Status Iface::AddNetwork(
- android::sp<fi::w1::wpa_supplicant::INetwork> *network_object_out)
+Return<void> Iface::getName(getName_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID, ifname_);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
+}
+
+Return<void> Iface::addNetwork(addNetwork_cb _hidl_cb)
+{
+ android::sp<ISupplicantNetwork> network;
+ struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID, network);
+ }
struct wpa_ssid *ssid = wpa_supplicant_add_network(wpa_s);
if (!ssid) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "wpa_supplicant couldn't add this network.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
}
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
hidl_manager->getNetworkHidlObjectByIfnameAndNetworkId(
- wpa_s->ifname, ssid->id, network_object_out)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant encountered a hidl error.");
+ wpa_s->ifname, ssid->id, &network)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
}
-android::hidl::Status Iface::RemoveNetwork(int network_id)
+Return<void> Iface::removeNetwork(uint32_t id, removeNetwork_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+ }
- int result = wpa_supplicant_remove_network(wpa_s, network_id);
+ int result = wpa_supplicant_remove_network(wpa_s, id);
if (result == -1) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_NETWORK_UNKNOWN,
- "wpa_supplicant does not control this network.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN);
}
- if (result == -2) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant couldn't remove this network.");
+ if (result != 0) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Iface::GetNetwork(
- int network_id,
- android::sp<fi::w1::wpa_supplicant::INetwork> *network_object_out)
+Return<void> Iface::getNetwork(uint32_t id, getNetwork_cb _hidl_cb)
{
+ android::sp<ISupplicantNetwork> network;
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID, network);
+ }
- struct wpa_ssid *ssid = wpa_config_get_network(wpa_s->conf, network_id);
+ struct wpa_ssid *ssid = wpa_config_get_network(wpa_s->conf, id);
if (!ssid) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_NETWORK_UNKNOWN,
- "wpa_supplicant does not control this network.");
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN, network);
}
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
hidl_manager->getNetworkHidlObjectByIfnameAndNetworkId(
- wpa_s->ifname, ssid->id, network_object_out)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant encountered a hidl error.");
+ wpa_s->ifname, ssid->id, &network)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
}
-android::hidl::Status Iface::RegisterCallback(
- const android::sp<fi::w1::wpa_supplicant::IIfaceCallback> &callback)
+Return<void> Iface::listNetworks(listNetworks_cb _hidl_cb)
+{
+ std::vector<uint32_t> network_ids;
+
+ struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID, network_ids);
+ }
+
+ for (struct wpa_ssid *wpa_ssid = wpa_s->conf->ssid; wpa_ssid;
+ wpa_ssid = wpa_ssid->next) {
+ network_ids.emplace_back(wpa_ssid->id);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, network_ids);
+}
+
+Return<void> Iface::registerCallback(
+ const sp<ISupplicantIfaceCallback> &callback, registerCallback_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+ }
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
hidl_manager->addIfaceCallbackHidlObject(ifname_, callback)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant encountered a hidl error.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Iface::Reassociate()
+Return<void> Iface::reassociate(reassociate_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+ }
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_IFACE_DISABLED);
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_DISABLED);
}
- wpas_request_connection(wpa_s);
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Iface::Reconnect()
+Return<void> Iface::reconnect(reconnect_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+ }
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_IFACE_DISABLED);
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_DISABLED);
}
if (!wpa_s->disconnected) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_IFACE_NOT_DISCONNECTED);
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_NOT_DISCONNECTED);
}
+
wpas_request_connection(wpa_s);
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Iface::Disconnect()
+Return<void> Iface::disconnect(disconnect_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+ }
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_IFACE_DISABLED);
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_DISABLED);
}
+
wpas_request_disconnection(wpa_s);
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Iface::SetPowerSave(bool enable)
+Return<void> Iface::setPowerSave(bool enable, setPowerSave_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+ }
+
if (wpa_drv_set_p2p_powersave(wpa_s, enable, -1, -1)) {
- const std::string error_msg = "Failed setting power save mode" +
- std::to_string(enable) + ".";
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, error_msg.c_str());
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Iface::InitiateTDLSDiscover(
- const std::vector<uint8_t> &mac_address)
+Return<void> Iface::initiateTdlsDiscover(
+ const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
+ initiateTdlsDiscover_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
-
- if (mac_address.size() != MAC_ADDRESS_LEN) {
- const std::string error_msg =
- "Invalid MAC address value length: " +
- std::to_string(mac_address.size()) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
}
+
+ if (!mac_address.data()) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+ }
+
int ret;
const u8 *peer = mac_address.data();
if (wpa_tdls_is_external_setup(wpa_s->wpa)) {
@@ -199,26 +222,25 @@
ret = wpa_drv_tdls_oper(wpa_s, TDLS_DISCOVERY_REQ, peer);
}
if (ret) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "Failed to initiate TDLS Discover.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Iface::InitiateTDLSSetup(
- const std::vector<uint8_t> &mac_address)
+Return<void> Iface::initiateTdlsSetup(
+ const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
+ initiateTdlsSetup_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
-
- if (mac_address.size() != MAC_ADDRESS_LEN) {
- const std::string error_msg =
- "Invalid MAC address value length: " +
- std::to_string(mac_address.size()) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
}
+
+ if (!mac_address.data()) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+ }
+
int ret;
const u8 *peer = mac_address.data();
if (wpa_tdls_is_external_setup(wpa_s->wpa) &&
@@ -229,26 +251,25 @@
ret = wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, peer);
}
if (ret) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "Failed to initiate TDLS Setup.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Iface::InitiateTDLSTeardown(
- const std::vector<uint8_t> &mac_address)
+Return<void> Iface::initiateTdlsTeardown(
+ const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
+ initiateTdlsTeardown_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
- RETURN_IF_IFACE_INVALID(wpa_s);
-
- if (mac_address.size() != MAC_ADDRESS_LEN) {
- const std::string error_msg =
- "Invalid MAC address value length: " +
- std::to_string(mac_address.size()) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
}
+
+ if (!mac_address.data()) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+ }
+
int ret;
const u8 *peer = mac_address.data();
if (wpa_tdls_is_external_setup(wpa_s->wpa) &&
@@ -258,22 +279,29 @@
} else {
ret = wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN, peer);
}
+
if (ret) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "Failed to initiate TDLS Teardown.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
/**
- * Retrieve the underlying |wpa_supplicant| struct pointer for
- * this iface.
- * If the underlying iface is removed, then all RPC method calls
- * on this object will return failure.
+ * Retrieve the underlying |wpa_supplicant| struct
+ * pointer for this iface.
+ * If the underlying iface is removed, then all RPC method calls on this object
+ * will return failure.
*/
wpa_supplicant *Iface::retrieveIfacePtr()
{
return wpa_supplicant_get_iface(
(struct wpa_global *)wpa_global_, ifname_.c_str());
}
-} // namespace wpa_supplicant_hidl
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
diff --git a/wpa_supplicant/hidl/iface.h b/wpa_supplicant/hidl/iface.h
index 51d7f39..3be2675 100644
--- a/wpa_supplicant/hidl/iface.h
+++ b/wpa_supplicant/hidl/iface.h
@@ -12,8 +12,9 @@
#include <android-base/macros.h>
-#include "fi/w1/wpa_supplicant/BnIface.h"
-#include "fi/w1/wpa_supplicant/INetwork.h"
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantIface.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantIfaceCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantNetwork.h>
extern "C" {
#include "utils/common.h"
@@ -22,55 +23,66 @@
#include "driver_i.h"
}
-namespace wpa_supplicant_hidl {
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
/**
* Implementation of Iface hidl object. Each unique hidl
* object is used for control operations on a specific interface
* controlled by wpa_supplicant.
*/
-class Iface : public fi::w1::wpa_supplicant::BnIface
+class Iface : public android::hardware::wifi::supplicant::V1_0::ISupplicantIface
{
public:
- Iface(struct wpa_global *wpa_global, const char ifname[]);
+ Iface(struct wpa_global* wpa_global, const char ifname[]);
~Iface() override = default;
- // Hidl methods exposed in aidl.
- android::hidl::Status GetName(std::string *iface_name_out) override;
- android::hidl::Status AddNetwork(
- android::sp<fi::w1::wpa_supplicant::INetwork> *network_object_out)
- override;
- android::hidl::Status RemoveNetwork(int network_id) override;
- android::hidl::Status GetNetwork(
- int network_id,
- android::sp<fi::w1::wpa_supplicant::INetwork> *network_object_out)
- override;
- android::hidl::Status RegisterCallback(
- const android::sp<fi::w1::wpa_supplicant::IIfaceCallback> &callback)
- override;
- android::hidl::Status Reassociate() override;
- android::hidl::Status Reconnect() override;
- android::hidl::Status Disconnect() override;
- android::hidl::Status SetPowerSave(bool enable) override;
- android::hidl::Status InitiateTDLSDiscover(
- const std::vector<uint8_t> &mac_address) override;
- android::hidl::Status InitiateTDLSSetup(
- const std::vector<uint8_t> &mac_address) override;
- android::hidl::Status InitiateTDLSTeardown(
- const std::vector<uint8_t> &mac_address) override;
+ // Hidl methods exposed.
+ Return<void> getName(getName_cb _hidl_cb) override;
+ Return<void> addNetwork(addNetwork_cb _hidl_cb) override;
+ Return<void> removeNetwork(
+ uint32_t id, removeNetwork_cb _hidl_cb) override;
+ Return<void> getNetwork(uint32_t id, getNetwork_cb _hidl_cb) override;
+ Return<void> listNetworks(listNetworks_cb _hidl_cb) override;
+ Return<void> registerCallback(
+ const sp<ISupplicantIfaceCallback>& callback,
+ registerCallback_cb _hidl_cb) override;
+ Return<void> reassociate(reassociate_cb _hidl_cb) override;
+ Return<void> reconnect(reconnect_cb _hidl_cb) override;
+ Return<void> disconnect(disconnect_cb _hidl_cb) override;
+ Return<void> setPowerSave(
+ bool enable, setPowerSave_cb _hidl_cb) override;
+ Return<void> initiateTdlsDiscover(
+ const hidl_array<uint8_t, 6 /* 6 */>& mac_address,
+ initiateTdlsDiscover_cb _hidl_cb) override;
+ Return<void> initiateTdlsSetup(
+ const hidl_array<uint8_t, 6 /* 6 */>& mac_address,
+ initiateTdlsSetup_cb _hidl_cb) override;
+ Return<void> initiateTdlsTeardown(
+ const hidl_array<uint8_t, 6 /* 6 */>& mac_address,
+ initiateTdlsTeardown_cb _hidl_cb) override;
private:
- struct wpa_supplicant *retrieveIfacePtr();
+ struct wpa_supplicant* retrieveIfacePtr();
// Reference to the global wpa_struct. This is assumed to be valid for
// the lifetime of the process.
- const struct wpa_global *wpa_global_;
+ const struct wpa_global* wpa_global_;
// Name of the iface this hidl object controls
const std::string ifname_;
DISALLOW_COPY_AND_ASSIGN(Iface);
};
-} // namespace wpa_supplicant_hidl
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
#endif // WPA_SUPPLICANT_HIDL_IFACE_H
diff --git a/wpa_supplicant/hidl/network.cpp b/wpa_supplicant/hidl/network.cpp
index 97a7368..a7824fe 100644
--- a/wpa_supplicant/hidl/network.cpp
+++ b/wpa_supplicant/hidl/network.cpp
@@ -8,58 +8,54 @@
*/
#include "hidl_manager.h"
+#include "hidl_return_macros.h"
#include "network.h"
namespace {
-constexpr int kAllowedKeyMgmtMask =
- (fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_NONE |
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_WPA_PSK |
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_WPA_EAP |
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_IEEE8021X);
-constexpr int kAllowedProtoMask =
- (fi::w1::wpa_supplicant::INetwork::PROTO_MASK_WPA |
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_RSN |
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_OSEN);
-constexpr int kAllowedAuthAlgMask =
- (fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_OPEN |
- fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_SHARED |
- fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_LEAP);
-constexpr int kAllowedGroupCipherMask =
- (fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_WEP40 |
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_WEP104 |
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_TKIP |
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_CCMP);
-constexpr int kAllowedPairwiseCipherMask =
- (fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_NONE |
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_TKIP |
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_CCMP);
+using android::hardware::wifi::supplicant::V1_0::ISupplicantNetwork;
+using android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
-constexpr int kEapMethodMax =
- fi::w1::wpa_supplicant::INetwork::EAP_METHOD_WFA_UNAUTH_TLS + 1;
-constexpr int kEapMethodMin = fi::w1::wpa_supplicant::INetwork::EAP_METHOD_PEAP;
+constexpr uint8_t kZeroBssid[6] = {0, 0, 0, 0, 0, 0};
+
+constexpr uint32_t kAllowedKeyMgmtMask =
+ (static_cast<uint32_t>(ISupplicantNetwork::KeyMgmtMask::NONE) |
+ static_cast<uint32_t>(ISupplicantNetwork::KeyMgmtMask::WPA_PSK) |
+ static_cast<uint32_t>(ISupplicantNetwork::KeyMgmtMask::WPA_EAP) |
+ static_cast<uint32_t>(ISupplicantNetwork::KeyMgmtMask::IEEE8021X));
+constexpr uint32_t kAllowedproto_mask =
+ (static_cast<uint32_t>(ISupplicantNetwork::ProtoMask::WPA) |
+ static_cast<uint32_t>(ISupplicantNetwork::ProtoMask::RSN) |
+ static_cast<uint32_t>(ISupplicantNetwork::ProtoMask::OSEN));
+constexpr uint32_t kAllowedauth_alg_mask =
+ (static_cast<uint32_t>(ISupplicantNetwork::AuthAlgMask::OPEN) |
+ static_cast<uint32_t>(ISupplicantNetwork::AuthAlgMask::SHARED) |
+ static_cast<uint32_t>(ISupplicantNetwork::AuthAlgMask::LEAP));
+constexpr uint32_t kAllowedgroup_cipher_mask =
+ (static_cast<uint32_t>(ISupplicantNetwork::GroupCipherMask::WEP40) |
+ static_cast<uint32_t>(ISupplicantNetwork::GroupCipherMask::WEP104) |
+ static_cast<uint32_t>(ISupplicantNetwork::GroupCipherMask::TKIP) |
+ static_cast<uint32_t>(ISupplicantNetwork::GroupCipherMask::CCMP));
+constexpr uint32_t kAllowedpairwise_cipher_mask =
+ (static_cast<uint32_t>(ISupplicantNetwork::PairwiseCipherMask::NONE) |
+ static_cast<uint32_t>(ISupplicantNetwork::PairwiseCipherMask::TKIP) |
+ static_cast<uint32_t>(ISupplicantNetwork::PairwiseCipherMask::CCMP));
+
+constexpr uint32_t kEapMethodMax =
+ static_cast<uint32_t>(ISupplicantNetwork::EapMethod::WFA_UNAUTH_TLS) + 1;
constexpr char const *kEapMethodStrings[kEapMethodMax] = {
"PEAP", "TLS", "TTLS", "PWD", "SIM", "AKA", "AKA'", "WFA-UNAUTH-TLS"};
-
-constexpr int kEapPhase2MethodMax =
- fi::w1::wpa_supplicant::INetwork::EAP_PHASE2_METHOD_GTC + 1;
-constexpr int kEapPhase2MethodMin =
- fi::w1::wpa_supplicant::INetwork::EAP_PHASE2_METHOD_NONE;
+constexpr uint32_t kEapPhase2MethodMax =
+ static_cast<uint32_t>(ISupplicantNetwork::EapPhase2Method::GTC) + 1;
constexpr char const *kEapPhase2MethodStrings[kEapPhase2MethodMax] = {
"NULL", "PAP", "MSCHAP", "MSCHAPV2", "GTC"};
} // namespace
-namespace wpa_supplicant_hidl {
-
-#define RETURN_IF_NETWORK_INVALID(wpa_ssid) \
- { \
- if (!wpa_ssid) { \
- return android::hidl::Status:: \
- fromServiceSpecificError( \
- ERROR_NETWORK_INVALID, \
- "wpa_supplicant does not control this " \
- "network."); \
- } \
- } // #define RETURN_IF_NETWORK_INVALID(wpa_ssid)
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
Network::Network(
struct wpa_global *wpa_global, const char ifname[], int network_id)
@@ -67,74 +63,92 @@
{
}
-android::hidl::Status Network::GetId(int *network_id_out)
+Return<void> Network::getId(getId_cb _hidl_cb)
{
- RETURN_IF_NETWORK_INVALID(retrieveNetworkPtr());
- *network_id_out = network_id_;
- return android::hidl::Status::ok();
+ uint32_t id = UINT32_MAX;
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID, id);
+ }
+
+ id = network_id_;
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, id);
}
-android::hidl::Status Network::GetInterfaceName(std::string *ifname_out)
+Return<void> Network::getInterfaceName(getInterfaceName_cb _hidl_cb)
{
- RETURN_IF_NETWORK_INVALID(retrieveNetworkPtr());
- *ifname_out = ifname_;
- return android::hidl::Status::ok();
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID, ifname_);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
}
-android::hidl::Status Network::RegisterCallback(
- const android::sp<fi::w1::wpa_supplicant::INetworkCallback> &callback)
+Return<void> Network::registerCallback(
+ const sp<ISupplicantNetworkCallback> &callback,
+ registerCallback_cb _hidl_cb)
{
- RETURN_IF_NETWORK_INVALID(retrieveNetworkPtr());
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
+
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
hidl_manager->addNetworkCallbackHidlObject(
ifname_, network_id_, callback)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant encountered a hidl error.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetSSID(const std::vector<uint8_t> &ssid)
+Return<void> Network::setSsid(
+ const hidl_vec<uint8_t> &ssid, setSsid_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- if (ssid.empty() || ssid.size() > SSID_MAX_LEN) {
- const std::string error_msg = "Invalid SSID value length: " +
- std::to_string(ssid.size()) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
}
- android::hidl::Status status = setByteArrayFieldAndResetState(
- ssid.data(), ssid.size(), &(wpa_ssid->ssid), &(wpa_ssid->ssid_len),
- "ssid");
- if (status.isOk() && wpa_ssid->passphrase) {
+
+ if (ssid.size() == 0 ||
+ ssid.size() >
+ static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ SSID_MAX_LEN_IN_BYTES)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+ }
+
+ if (setByteArrayFieldAndResetState(
+ ssid.data(), ssid.size(), &(wpa_ssid->ssid),
+ &(wpa_ssid->ssid_len), "ssid")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+ if (wpa_ssid->passphrase) {
wpa_config_update_psk(wpa_ssid);
}
- return status;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetBSSID(const std::vector<uint8_t> &bssid)
+Return<void> Network::setBssid(
+ const hidl_array<uint8_t, 6 /* 6 */> &bssid, setBssid_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- if (!bssid.empty() && bssid.size() != BSSID_LEN) {
- const std::string error_msg = "Invalid BSSID value length: " +
- std::to_string(bssid.size()) +
- ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
}
+
+ if (!bssid.data()) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+ }
+
int prev_bssid_set = wpa_ssid->bssid_set;
u8 prev_bssid[ETH_ALEN];
os_memcpy(prev_bssid, wpa_ssid->bssid, ETH_ALEN);
- // Empty array is used to clear out the BSSID value.
- if (bssid.empty()) {
+ // Zero'ed array is used to clear out the BSSID value.
+ if (os_memcmp(bssid.data(), kZeroBssid, ETH_ALEN) == 0) {
wpa_ssid->bssid_set = 0;
wpa_printf(MSG_MSGDUMP, "BSSID any");
} else {
@@ -147,161 +161,163 @@
os_memcmp(wpa_ssid->bssid, prev_bssid, ETH_ALEN) != 0)) {
wpas_notify_network_bssid_set_changed(wpa_s, wpa_ssid);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetScanSSID(bool enable)
+Return<void> Network::setScanSsid(bool enable, setScanSsid_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
wpa_ssid->scan_ssid = enable ? 1 : 0;
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetKeyMgmt(int32_t key_mgmt_mask)
+Return<void> Network::setKeyMgmt(uint32_t key_mgmt_mask, setKeyMgmt_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
if (key_mgmt_mask & ~kAllowedKeyMgmtMask) {
- const std::string error_msg = "Invalid key_mgmt value: " +
- std::to_string(key_mgmt_mask) +
- ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
wpa_ssid->key_mgmt = key_mgmt_mask;
wpa_printf(MSG_MSGDUMP, "key_mgmt: 0x%x", wpa_ssid->key_mgmt);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetProto(int32_t proto_mask)
+Return<void> Network::setProto(uint32_t proto_mask, setProto_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- if (proto_mask & ~kAllowedProtoMask) {
- const std::string error_msg =
- "Invalid proto value: " + std::to_string(proto_mask) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (proto_mask & ~kAllowedproto_mask) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
wpa_ssid->proto = proto_mask;
wpa_printf(MSG_MSGDUMP, "proto: 0x%x", wpa_ssid->proto);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetAuthAlg(int32_t auth_alg_mask)
+Return<void> Network::setAuthAlg(
+ uint32_t auth_alg_mask,
+ std::function<void(const SupplicantStatus &status)> _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- if (auth_alg_mask & ~kAllowedAuthAlgMask) {
- const std::string error_msg = "Invalid auth_alg value: " +
- std::to_string(auth_alg_mask) +
- ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (auth_alg_mask & ~kAllowedauth_alg_mask) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
wpa_ssid->auth_alg = auth_alg_mask;
wpa_printf(MSG_MSGDUMP, "auth_alg: 0x%x", wpa_ssid->auth_alg);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetGroupCipher(int32_t group_cipher_mask)
+Return<void> Network::setGroupCipher(
+ uint32_t group_cipher_mask, setGroupCipher_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- if (group_cipher_mask & ~kAllowedGroupCipherMask) {
- const std::string error_msg =
- "Invalid group_cipher value: " +
- std::to_string(group_cipher_mask) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (group_cipher_mask & ~kAllowedgroup_cipher_mask) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
wpa_ssid->group_cipher = group_cipher_mask;
wpa_printf(MSG_MSGDUMP, "group_cipher: 0x%x", wpa_ssid->group_cipher);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetPairwiseCipher(int32_t pairwise_cipher_mask)
+Return<void> Network::setPairwiseCipher(
+ uint32_t pairwise_cipher_mask, setPairwiseCipher_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- if (pairwise_cipher_mask & ~kAllowedPairwiseCipherMask) {
- const std::string error_msg =
- "Invalid pairwise_cipher value: " +
- std::to_string(pairwise_cipher_mask) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (pairwise_cipher_mask & ~kAllowedpairwise_cipher_mask) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
wpa_ssid->pairwise_cipher = pairwise_cipher_mask;
wpa_printf(
MSG_MSGDUMP, "pairwise_cipher: 0x%x", wpa_ssid->pairwise_cipher);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetPskPassphrase(const std::string &psk)
+Return<void> Network::setPskPassphrase(
+ const hidl_string &psk, setPskPassphrase_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
if (isPskPassphraseValid(psk)) {
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- "Invalid Psk passphrase value.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
if (wpa_ssid->passphrase &&
os_strlen(wpa_ssid->passphrase) == psk.size() &&
os_memcmp(wpa_ssid->passphrase, psk.c_str(), psk.size()) == 0) {
- return android::hidl::Status::ok();
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
// Flag to indicate if raw psk is calculated or not using
// |wpa_config_update_psk|. Deferred if ssid not already set.
wpa_ssid->psk_set = 0;
- android::hidl::Status status = setStringKeyFieldAndResetState(
- psk.data(), &(wpa_ssid->passphrase), "psk passphrase");
- if (status.isOk() && wpa_ssid->ssid_len) {
+ if (setStringKeyFieldAndResetState(
+ psk.c_str(), &(wpa_ssid->passphrase), "psk passphrase")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+ if (wpa_ssid->ssid_len) {
wpa_config_update_psk(wpa_ssid);
}
- return status;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetWepKey(
- int key_idx, const std::vector<uint8_t> &wep_key)
+Return<void> Network::setWepKey(
+ uint32_t key_idx, const hidl_vec<uint8_t> &wep_key, setWepKey_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- if (key_idx < 0 || key_idx >= WEP_KEYS_MAX_NUM) {
- const std::string error_msg =
- "Invalid Wep Key index: " + std::to_string(key_idx) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
}
- if (wep_key.size() != WEP40_KEY_LEN &&
- wep_key.size() != WEP104_KEY_LEN) {
- const std::string error_msg = "Invalid Wep Key value length: " +
- std::to_string(wep_key.size()) +
- ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+
+ if (key_idx >=
+ static_cast<uint32_t>(
+ ISupplicantNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+ }
+ if (wep_key.size() !=
+ static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ WEP40_KEY_LEN_IN_BYTES) &&
+ wep_key.size() !=
+ static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ WEP104_KEY_LEN_IN_BYTES)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
os_memcpy(wpa_ssid->wep_key[key_idx], wep_key.data(), wep_key.size());
wpa_ssid->wep_key_len[key_idx] = wep_key.size();
@@ -310,61 +326,60 @@
MSG_MSGDUMP, msg_dump_title.c_str(), wpa_ssid->wep_key[key_idx],
wpa_ssid->wep_key_len[key_idx]);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetWepTxKeyIdx(int32_t wep_tx_key_idx)
+Return<void> Network::setWepTxKeyIdx(
+ uint32_t key_idx, setWepTxKeyIdx_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- if (wep_tx_key_idx < 0 || wep_tx_key_idx >= WEP_KEYS_MAX_NUM) {
- const std::string error_msg = "Invalid Wep Key index: " +
- std::to_string(wep_tx_key_idx) +
- ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
}
- wpa_ssid->wep_tx_keyidx = wep_tx_key_idx;
+
+ if (key_idx >=
+ static_cast<uint32_t>(
+ ISupplicantNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+ }
+ wpa_ssid->wep_tx_keyidx = key_idx;
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetRequirePMF(bool enable)
+Return<void> Network::setRequirePmf(bool enable, setRequirePmf_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
wpa_ssid->ieee80211w =
enable ? MGMT_FRAME_PROTECTION_REQUIRED : NO_MGMT_FRAME_PROTECTION;
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapMethod(int32_t method)
+Return<void> Network::setEapMethod(
+ ISupplicantNetwork::EapMethod method, setEapMethod_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
int retrieved_vendor, retrieved_method;
- if (method < kEapMethodMin || method >= kEapMethodMax) {
- const std::string error_msg =
- "Invalid EAP method: " + std::to_string(method) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
- }
- const char *method_str = kEapMethodStrings[method];
+ const char *method_str =
+ kEapMethodStrings[static_cast<uint32_t>(method)];
// This string lookup is needed to check if the device supports the
// corresponding EAP type.
retrieved_method = eap_peer_get_type(method_str, &retrieved_vendor);
if (retrieved_vendor == EAP_VENDOR_IETF &&
retrieved_method == EAP_TYPE_NONE) {
- const std::string error_msg = "Cannot get EAP method type: " +
- std::to_string(method) + ".";
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, error_msg.c_str());
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
if (wpa_ssid->eap.eap_methods) {
@@ -378,8 +393,7 @@
wpa_ssid->eap.eap_methods =
(eap_method_type *)os_malloc(sizeof(eap_method_type) * 2);
if (!wpa_ssid->eap.eap_methods) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "Memory allocation failed.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
wpa_ssid->eap.eap_methods[0].vendor = retrieved_vendor;
wpa_ssid->eap.eap_methods[0].method = retrieved_method;
@@ -399,284 +413,424 @@
MSG_MSGDUMP, "eap methods", (u8 *)wpa_ssid->eap.eap_methods,
sizeof(eap_method_type) * 2);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapPhase2Method(int32_t method)
+Return<void> Network::setEapPhase2Method(
+ ISupplicantNetwork::EapPhase2Method method, setEapPhase2Method_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- if (method < kEapPhase2MethodMin || method >= kEapMethodMax) {
- const std::string error_msg = "Invalid EAP Phase2 method: " +
- std::to_string(method) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
}
- return setStringFieldAndResetState(
- kEapPhase2MethodStrings[method], &(wpa_ssid->eap.phase2),
- "eap phase2");
-}
-android::hidl::Status Network::SetEapIdentity(
- const std::vector<uint8_t> &identity)
-{
- struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- return setByteArrayFieldAndResetState(
- identity.data(), identity.size(), &(wpa_ssid->eap.identity),
- &(wpa_ssid->eap.identity_len), "eap identity");
-}
-
-android::hidl::Status Network::SetEapAnonymousIdentity(
- const std::vector<uint8_t> &identity)
-{
- struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- return setByteArrayFieldAndResetState(
- identity.data(), identity.size(),
- &(wpa_ssid->eap.anonymous_identity),
- &(wpa_ssid->eap.anonymous_identity_len), "eap anonymous_identity");
-}
-
-android::hidl::Status Network::SetEapPassword(
- const std::vector<uint8_t> &password)
-{
- struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- android::hidl::Status status = setByteArrayKeyFieldAndResetState(
- password.data(), password.size(), &(wpa_ssid->eap.password),
- &(wpa_ssid->eap.password_len), "eap password");
- if (status.isOk()) {
- wpa_ssid->eap.flags &= ~EAP_CONFIG_FLAGS_PASSWORD_NTHASH;
- wpa_ssid->eap.flags &= ~EAP_CONFIG_FLAGS_EXT_PASSWORD;
+ if (setStringFieldAndResetState(
+ kEapPhase2MethodStrings[static_cast<uint32_t>(method)],
+ &(wpa_ssid->eap.phase2), "eap phase2")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return status;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapCACert(const std::string &path)
+Return<void> Network::setEapIdentity(
+ const hidl_vec<uint8_t> &identity, setEapIdentity_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- return setStringFieldAndResetState(
- path.c_str(), &(wpa_ssid->eap.ca_cert), "eap ca_cert");
+ if (setByteArrayFieldAndResetState(
+ identity.data(), identity.size(), &(wpa_ssid->eap.identity),
+ &(wpa_ssid->eap.identity_len), "eap identity")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapCAPath(const std::string &path)
+Return<void> Network::setEapAnonymousIdentity(
+ const hidl_vec<uint8_t> &identity, setEapAnonymousIdentity_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- return setStringFieldAndResetState(
- path.c_str(), &(wpa_ssid->eap.ca_path), "eap ca_path");
+ if (setByteArrayFieldAndResetState(
+ identity.data(), identity.size(),
+ &(wpa_ssid->eap.anonymous_identity),
+ &(wpa_ssid->eap.anonymous_identity_len),
+ "eap anonymous_identity")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapClientCert(const std::string &path)
+Return<void> Network::setEapPassword(
+ const hidl_vec<uint8_t> &password, setEapPassword_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- return setStringFieldAndResetState(
- path.c_str(), &(wpa_ssid->eap.client_cert), "eap client_cert");
+ if (setByteArrayKeyFieldAndResetState(
+ password.data(), password.size(), &(wpa_ssid->eap.password),
+ &(wpa_ssid->eap.password_len), "eap password")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+ wpa_ssid->eap.flags &= ~EAP_CONFIG_FLAGS_PASSWORD_NTHASH;
+ wpa_ssid->eap.flags &= ~EAP_CONFIG_FLAGS_EXT_PASSWORD;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapPrivateKey(const std::string &path)
+Return<void> Network::setEapCACert(
+ const hidl_string &path, setEapCACert_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- return setStringFieldAndResetState(
- path.c_str(), &(wpa_ssid->eap.private_key), "eap private_key");
+ if (setStringFieldAndResetState(
+ path.c_str(), &(wpa_ssid->eap.ca_cert), "eap ca_cert")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapSubjectMatch(const std::string &match)
-
+Return<void> Network::setEapCAPath(
+ const hidl_string &path, setEapCAPath_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- return setStringFieldAndResetState(
- match.c_str(), &(wpa_ssid->eap.subject_match), "eap subject_match");
+ if (setStringFieldAndResetState(
+ path.c_str(), &(wpa_ssid->eap.ca_path), "eap ca_path")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapAltSubjectMatch(const std::string &match)
+Return<void> Network::setEapClientCert(
+ const hidl_string &path, setEapClientCert_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- return setStringFieldAndResetState(
- match.c_str(), &(wpa_ssid->eap.altsubject_match),
- "eap altsubject_match");
+ if (setStringFieldAndResetState(
+ path.c_str(), &(wpa_ssid->eap.client_cert),
+ "eap client_cert")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapEngine(bool enable)
+Return<void> Network::setEapPrivateKey(
+ const hidl_string &path, setEapPrivateKey_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
+
+ if (setStringFieldAndResetState(
+ path.c_str(), &(wpa_ssid->eap.private_key),
+ "eap private_key")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+}
+
+Return<void> Network::setEapSubjectMatch(
+ const hidl_string &match, setEapSubjectMatch_cb _hidl_cb)
+{
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
+
+ if (setStringFieldAndResetState(
+ match.c_str(), &(wpa_ssid->eap.subject_match),
+ "eap subject_match")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+}
+
+Return<void> Network::setEapAltSubjectMatch(
+ const hidl_string &match, setEapAltSubjectMatch_cb _hidl_cb)
+{
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
+
+ if (setStringFieldAndResetState(
+ match.c_str(), &(wpa_ssid->eap.altsubject_match),
+ "eap altsubject_match")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+}
+
+Return<void> Network::setEapEngine(bool enable, setEapEngine_cb _hidl_cb)
+{
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
wpa_ssid->eap.engine = enable ? 1 : 0;
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapEngineID(const std::string &id)
+Return<void> Network::setEapEngineID(
+ const hidl_string &id, setEapEngineID_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- return setStringFieldAndResetState(
- id.c_str(), &(wpa_ssid->eap.engine_id), "eap engine_id");
- return android::hidl::Status::ok();
+ if (setStringFieldAndResetState(
+ id.c_str(), &(wpa_ssid->eap.engine_id), "eap engine_id")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SetEapDomainSuffixMatch(
- const std::string &match)
-
+Return<void> Network::setEapDomainSuffixMatch(
+ const hidl_string &match, setEapDomainSuffixMatch_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- return setStringFieldAndResetState(
- match.c_str(), &(wpa_ssid->eap.domain_suffix_match),
- "eap domain_suffix_match");
+ if (setStringFieldAndResetState(
+ match.c_str(), &(wpa_ssid->eap.domain_suffix_match),
+ "eap domain_suffix_match")) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::GetSSID(std::vector<uint8_t> *ssid)
+Return<void> Network::getSsid(getSsid_cb _hidl_cb)
{
+ std::vector<uint8_t> ssid;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID, ssid);
+ }
- ssid->assign(wpa_ssid->ssid, wpa_ssid->ssid + wpa_ssid->ssid_len);
- return android::hidl::Status::ok();
+ ssid.assign(wpa_ssid->ssid, wpa_ssid->ssid + wpa_ssid->ssid_len);
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, ssid);
}
-android::hidl::Status Network::GetBSSID(std::vector<uint8_t> *bssid)
+Return<void> Network::getBssid(getBssid_cb _hidl_cb)
{
+ hidl_array<uint8_t, 6> bssid;
+ os_memcpy(bssid.data(), kZeroBssid, ETH_ALEN);
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID, bssid);
+ }
if (wpa_ssid->bssid_set) {
- bssid->assign(wpa_ssid->bssid, wpa_ssid->bssid + ETH_ALEN);
- } else {
- bssid->clear();
+ os_memcpy(bssid.data(), wpa_ssid->bssid, ETH_ALEN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, bssid);
}
-android::hidl::Status Network::GetScanSSID(bool *enable)
+Return<void> Network::getScanSsid(getScanSsid_cb _hidl_cb)
{
+ bool enabled = false;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID, enabled);
+ }
- *enable = (wpa_ssid->scan_ssid == 1);
- return android::hidl::Status::ok();
+ enabled = (wpa_ssid->scan_ssid == 1);
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, enabled);
}
-android::hidl::Status Network::GetKeyMgmt(int32_t *key_mgmt_mask)
+Return<void> Network::getKeyMgmt(getKeyMgmt_cb _hidl_cb)
{
+ uint32_t key_mgmt_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
- *key_mgmt_mask = wpa_ssid->key_mgmt;
- return android::hidl::Status::ok();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+ key_mgmt_mask);
+ }
+
+ key_mgmt_mask = wpa_ssid->key_mgmt;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, key_mgmt_mask);
}
-android::hidl::Status Network::GetProto(int32_t *proto_mask)
+Return<void> Network::getProto(getProto_cb _hidl_cb)
{
+ uint32_t proto_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
- *proto_mask = wpa_ssid->proto;
- return android::hidl::Status::ok();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID, proto_mask);
+ }
+
+ proto_mask = wpa_ssid->proto;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, proto_mask);
}
-android::hidl::Status Network::GetAuthAlg(int32_t *auth_alg_mask)
+Return<void> Network::getAuthAlg(getAuthAlg_cb _hidl_cb)
{
+ uint32_t auth_alg_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
- *auth_alg_mask = wpa_ssid->auth_alg;
- return android::hidl::Status::ok();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+ auth_alg_mask);
+ }
+
+ auth_alg_mask = wpa_ssid->auth_alg;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, auth_alg_mask);
}
-android::hidl::Status Network::GetGroupCipher(int32_t *group_cipher_mask)
+Return<void> Network::getGroupCipher(getGroupCipher_cb _hidl_cb)
{
+ uint32_t group_cipher_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
- *group_cipher_mask = wpa_ssid->group_cipher;
- return android::hidl::Status::ok();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+ group_cipher_mask);
+ }
+
+ group_cipher_mask = wpa_ssid->group_cipher;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, group_cipher_mask);
}
-android::hidl::Status Network::GetPairwiseCipher(
- int32_t *pairwise_cipher_mask)
+Return<void> Network::getPairwiseCipher(getPairwiseCipher_cb _hidl_cb)
{
+ uint32_t pairwise_cipher_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
- *pairwise_cipher_mask = wpa_ssid->pairwise_cipher;
- return android::hidl::Status::ok();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+ pairwise_cipher_mask);
+ }
+
+ pairwise_cipher_mask = wpa_ssid->pairwise_cipher;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, pairwise_cipher_mask);
}
-android::hidl::Status Network::GetPskPassphrase(std::string *psk)
+Return<void> Network::getPskPassphrase(getPskPassphrase_cb _hidl_cb)
{
+ hidl_string psk;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID, psk);
+ }
if (wpa_ssid->passphrase) {
- *psk = wpa_ssid->passphrase;
- } else {
- *psk = std::string();
+ psk = wpa_ssid->passphrase;
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, psk);
}
-android::hidl::Status Network::GetWepKey(
- int key_idx, std::vector<uint8_t> *wep_key)
+Return<void> Network::getWepKey(uint32_t key_idx, getWepKey_cb _hidl_cb)
{
+ std::vector<uint8_t> wep_key;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- if (key_idx < 0 || key_idx >= WEP_KEYS_MAX_NUM) {
- const std::string error_msg =
- "Invalid Wep Key index: " + std::to_string(key_idx) + ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID, wep_key);
+ return Void();
}
- wep_key->assign(
+ if (key_idx >=
+ static_cast<uint32_t>(
+ ISupplicantNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_ARGS_INVALID, wep_key);
+ }
+
+ wep_key.assign(
wpa_ssid->wep_key[key_idx],
wpa_ssid->wep_key[key_idx] + wpa_ssid->wep_key_len[key_idx]);
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, wep_key);
}
-android::hidl::Status Network::GetWepTxKeyIdx(int32_t *wep_tx_key_idx)
+Return<void> Network::getWepTxKeyIdx(getWepTxKeyIdx_cb _hidl_cb)
{
+ uint32_t wep_tx_key_idx = UINT32_MAX;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
- *wep_tx_key_idx = wpa_ssid->wep_tx_keyidx;
- return android::hidl::Status::ok();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+ wep_tx_key_idx);
+ }
+
+ wep_tx_key_idx = wpa_ssid->wep_tx_keyidx;
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, wep_tx_key_idx);
}
-android::hidl::Status Network::GetRequirePMF(bool *enable)
+Return<void> Network::getRequirePmf(getRequirePmf_cb _hidl_cb)
{
+ bool enabled = false;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID, enabled);
+ }
- *enable = (wpa_ssid->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED);
- return android::hidl::Status::ok();
+ enabled = (wpa_ssid->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED);
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, enabled);
}
-android::hidl::Status Network::Enable(bool no_connect)
+Return<void> Network::enable(bool no_connect, enable_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
- if (wpa_ssid->disabled == 2) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "Cannot use Enable with persistent P2P group");
+ if (wpa_ssid->disabled != 0) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
@@ -687,80 +841,178 @@
wpa_s->scan_min_time.usec = 0;
wpa_supplicant_enable_network(wpa_s, wpa_ssid);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::Disable()
+Return<void> Network::disable(disable_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
if (wpa_ssid->disabled == 2) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "Cannot use Disable with persistent P2P group");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
wpa_supplicant_disable_network(wpa_s, wpa_ssid);
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::Select()
+Return<void> Network::select(select_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
if (wpa_ssid->disabled == 2) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "Cannot use Select with persistent P2P group");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
wpa_s->scan_min_time.sec = 0;
wpa_s->scan_min_time.usec = 0;
wpa_supplicant_select_network(wpa_s, wpa_ssid);
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Network::SendNetworkResponse(
- int type, const std::string ¶m)
+Return<void> Network::sendNetworkEapSimGsmAuthResponse(
+ const ISupplicantNetwork::NetworkResponseEapSimGsmAuthParams ¶ms,
+ sendNetworkEapSimGsmAuthResponse_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
- RETURN_IF_NETWORK_INVALID(wpa_ssid);
-
- if (type < NETWORK_RSP_UNKNOWN || type > NETWORK_RSP_EXT_CERT_CHECK) {
- const std::string error_msg =
- "Invalid network response type: " + std::to_string(type) +
- ".";
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
}
- enum wpa_ctrl_req_type rtype = (enum wpa_ctrl_req_type)type;
+ // Convert the incoming parameters to a string to pass to
+ // wpa_supplicant.
+ std::string ctrl_rsp_param;
+ uint32_t kc_hex_len = params.kc.size() * 2 + 1;
+ char *kc_hex = (char *)malloc(kc_hex_len);
+ uint32_t sres_hex_len = params.sres.size() * 2 + 1;
+ char *sres_hex = (char *)malloc(sres_hex_len);
+ if (!kc_hex || !sres_hex) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+ wpa_snprintf_hex(
+ kc_hex, kc_hex_len, params.kc.data(), params.kc.size());
+ wpa_snprintf_hex(
+ sres_hex, sres_hex_len, params.sres.data(), params.sres.size());
+ ctrl_rsp_param += "kc:";
+ ctrl_rsp_param += kc_hex;
+ ctrl_rsp_param += " sres:";
+ ctrl_rsp_param += sres_hex;
+
+ enum wpa_ctrl_req_type rtype = WPA_CTRL_REQ_SIM;
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (wpa_supplicant_ctrl_rsp_handle(
- wpa_s, wpa_ssid, rtype, param.c_str())) {
- const std::string error_msg =
- "Failed handling network response: " +
- std::to_string(type) + ".";
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, error_msg.c_str());
+ wpa_s, wpa_ssid, rtype, ctrl_rsp_param.c_str())) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
eapol_sm_notify_ctrl_response(wpa_s->eapol);
- wpa_hexdump_ascii(
- MSG_DEBUG, "network response param", (const u8 *)param.c_str(),
- param.size());
- return android::hidl::Status::ok();
+ wpa_hexdump_ascii_key(
+ MSG_DEBUG, "network sim gsm auth response param",
+ (const u8 *)ctrl_rsp_param.c_str(), ctrl_rsp_param.size());
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+}
+
+Return<void> Network::sendNetworkEapSimUmtsAuthResponse(
+ const ISupplicantNetwork::NetworkResponseEapSimUmtsAuthParams ¶ms,
+ sendNetworkEapSimUmtsAuthResponse_cb _hidl_cb)
+{
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
+
+ // Convert the incoming parameters to a string to pass to
+ // wpa_supplicant.
+ std::string ctrl_rsp_param;
+ uint32_t ik_hex_len = params.ik.size() * 2 + 1;
+ char *ik_hex = (char *)malloc(ik_hex_len);
+ uint32_t ck_hex_len = params.ck.size() * 2 + 1;
+ char *ck_hex = (char *)malloc(ck_hex_len);
+ uint32_t res_hex_len = params.res.size() * 2 + 1;
+ char *res_hex = (char *)malloc(res_hex_len);
+ if (!ik_hex || !ck_hex || !res_hex) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+ wpa_snprintf_hex(
+ ik_hex, ik_hex_len, params.ik.data(), params.ik.size());
+ wpa_snprintf_hex(
+ ck_hex, ck_hex_len, params.ck.data(), params.ck.size());
+ wpa_snprintf_hex(
+ res_hex, res_hex_len, params.res.data(), params.res.size());
+ ctrl_rsp_param += "ik:";
+ ctrl_rsp_param += ik_hex;
+ ctrl_rsp_param += "ck:";
+ ctrl_rsp_param += ck_hex;
+ ctrl_rsp_param += " res:";
+ ctrl_rsp_param += res_hex;
+
+ enum wpa_ctrl_req_type rtype = WPA_CTRL_REQ_SIM;
+ struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+ if (wpa_supplicant_ctrl_rsp_handle(
+ wpa_s, wpa_ssid, rtype, ctrl_rsp_param.c_str())) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+ eapol_sm_notify_ctrl_response(wpa_s->eapol);
+ wpa_hexdump_ascii_key(
+ MSG_DEBUG, "network sim umts auth response param",
+ (const u8 *)ctrl_rsp_param.c_str(), ctrl_rsp_param.size());
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+}
+
+Return<void> Network::sendNetworkEapIdentityResponse(
+ const hidl_vec<uint8_t> &identity,
+ sendNetworkEapIdentityResponse_cb _hidl_cb)
+{
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
+ }
+
+ // Convert the incoming parameters to a string to pass to
+ // wpa_supplicant.
+ uint32_t identity_hex_len = identity.size() * 2 + 1;
+ char *identity_hex = (char *)malloc(identity_hex_len);
+ std::string ctrl_rsp_param;
+ if (!identity_hex) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+ wpa_snprintf_hex(
+ identity_hex, identity_hex_len, identity.data(), identity.size());
+ ctrl_rsp_param = identity_hex;
+
+ enum wpa_ctrl_req_type rtype = WPA_CTRL_REQ_EAP_IDENTITY;
+ struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+ if (wpa_supplicant_ctrl_rsp_handle(
+ wpa_s, wpa_ssid, rtype, ctrl_rsp_param.c_str())) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+ eapol_sm_notify_ctrl_response(wpa_s->eapol);
+ wpa_hexdump_ascii_key(
+ MSG_DEBUG, "network identity response param",
+ (const u8 *)ctrl_rsp_param.c_str(), ctrl_rsp_param.size());
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
/**
* Retrieve the underlying |wpa_ssid| struct pointer for
* this network.
- * If the underlying network is removed or the interface this network belong to
- * is removed, all RPC method calls on this object will return failure.
+ * If the underlying network is removed or the interface
+ * this network belong to
+ * is removed, all RPC method calls on this object will
+ * return failure.
*/
struct wpa_ssid *Network::retrieveNetworkPtr()
{
@@ -771,7 +1023,8 @@
}
/**
- * Retrieve the underlying |wpa_supplicant| struct pointer for
+ * Retrieve the underlying |wpa_supplicant| struct
+ * pointer for
* this network.
*/
struct wpa_supplicant *Network::retrieveIfacePtr()
@@ -785,10 +1038,14 @@
*
* Returns 0 if valid, 1 otherwise.
*/
-int Network::isPskPassphraseValid(const std::string &psk)
+int Network::isPskPassphraseValid(const hidl_string &psk)
{
- if (psk.size() < PSK_PASSPHRASE_MIN_LEN ||
- psk.size() > PSK_PASSPHRASE_MAX_LEN) {
+ if (psk.size() <
+ static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ PSK_PASSPHRASE_MIN_LEN_IN_BYTES) ||
+ psk.size() >
+ static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ PSK_PASSPHRASE_MAX_LEN_IN_BYTES)) {
return 1;
}
if (has_ctrl_char((u8 *)psk.c_str(), psk.size())) {
@@ -798,7 +1055,8 @@
}
/**
- * Reset internal wpa_supplicant state machine state after params update (except
+ * Reset internal wpa_supplicant state machine state
+ * after params update (except
* bssid).
*/
void Network::resetInternalStateAfterParamsUpdate()
@@ -810,8 +1068,10 @@
if (wpa_s->current_ssid == wpa_ssid || wpa_s->current_ssid == NULL) {
/*
- * Invalidate the EAP session cache if anything in the
- * current or previously used configuration changes.
+ * Invalidate the EAP session cache if
+ * anything in the
+ * current or previously used
+ * configuration changes.
*/
eapol_sm_invalidate_cached_session(wpa_s->eapol);
}
@@ -822,7 +1082,7 @@
* instance for this network.
* This function frees any existing data in these fields.
*/
-android::hidl::Status Network::setStringFieldAndResetState(
+int Network::setStringFieldAndResetState(
const char *value, uint8_t **to_update_field, const char *hexdump_prefix)
{
return setStringFieldAndResetState(
@@ -834,7 +1094,7 @@
* instance for this network.
* This function frees any existing data in these fields.
*/
-android::hidl::Status Network::setStringFieldAndResetState(
+int Network::setStringFieldAndResetState(
const char *value, char **to_update_field, const char *hexdump_prefix)
{
int value_len = strlen(value);
@@ -843,13 +1103,12 @@
}
*to_update_field = dup_binstr(value, value_len);
if (!(*to_update_field)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "Memory allocation failed.");
+ return 1;
}
wpa_hexdump_ascii(
MSG_MSGDUMP, hexdump_prefix, *to_update_field, value_len);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+ return 0;
}
/**
@@ -857,7 +1116,7 @@
* instance for this network.
* This function frees any existing data in these fields.
*/
-android::hidl::Status Network::setStringKeyFieldAndResetState(
+int Network::setStringKeyFieldAndResetState(
const char *value, char **to_update_field, const char *hexdump_prefix)
{
int value_len = strlen(value);
@@ -866,13 +1125,12 @@
}
*to_update_field = dup_binstr(value, value_len);
if (!(*to_update_field)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "Memory allocation failed.");
+ return 1;
}
wpa_hexdump_ascii_key(
MSG_MSGDUMP, hexdump_prefix, *to_update_field, value_len);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+ return 0;
}
/**
@@ -880,7 +1138,7 @@
* field in |wpa_ssid| structue instance for this network.
* This function frees any existing data in these fields.
*/
-android::hidl::Status Network::setByteArrayFieldAndResetState(
+int Network::setByteArrayFieldAndResetState(
const uint8_t *value, const size_t value_len, uint8_t **to_update_field,
size_t *to_update_field_len, const char *hexdump_prefix)
{
@@ -889,8 +1147,7 @@
}
*to_update_field = (uint8_t *)os_malloc(value_len);
if (!(*to_update_field)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "Memory allocation failed.");
+ return 1;
}
os_memcpy(*to_update_field, value, value_len);
*to_update_field_len = value_len;
@@ -899,7 +1156,7 @@
MSG_MSGDUMP, hexdump_prefix, *to_update_field,
*to_update_field_len);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+ return 0;
}
/**
@@ -907,7 +1164,7 @@
* length field in |wpa_ssid| structue instance for this network.
* This function frees any existing data in these fields.
*/
-android::hidl::Status Network::setByteArrayKeyFieldAndResetState(
+int Network::setByteArrayKeyFieldAndResetState(
const uint8_t *value, const size_t value_len, uint8_t **to_update_field,
size_t *to_update_field_len, const char *hexdump_prefix)
{
@@ -916,8 +1173,7 @@
}
*to_update_field = (uint8_t *)os_malloc(value_len);
if (!(*to_update_field)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC, "Memory allocation failed.");
+ return 1;
}
os_memcpy(*to_update_field, value, value_len);
*to_update_field_len = value_len;
@@ -926,7 +1182,12 @@
MSG_MSGDUMP, hexdump_prefix, *to_update_field,
*to_update_field_len);
resetInternalStateAfterParamsUpdate();
- return android::hidl::Status::ok();
+ return 0;
}
-} // namespace wpa_supplicant_hidl
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
diff --git a/wpa_supplicant/hidl/network.h b/wpa_supplicant/hidl/network.h
index 331e85a..614513f 100644
--- a/wpa_supplicant/hidl/network.h
+++ b/wpa_supplicant/hidl/network.h
@@ -12,7 +12,8 @@
#include <android-base/macros.h>
-#include "fi/w1/wpa_supplicant/BnNetwork.h"
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantNetwork.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantNetworkCallback.h>
extern "C" {
#include "utils/common.h"
@@ -25,115 +26,146 @@
#include "rsn_supp/wpa.h"
}
-namespace wpa_supplicant_hidl {
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
/**
* Implementation of Network hidl object. Each unique hidl
* object is used for control operations on a specific network
* controlled by wpa_supplicant.
*/
-class Network : public fi::w1::wpa_supplicant::BnNetwork
+class Network : public ISupplicantNetwork
{
public:
Network(
- struct wpa_global *wpa_global, const char ifname[], int network_id);
+ struct wpa_global* wpa_global, const char ifname[], int network_id);
~Network() override = default;
- // Hidl methods exposed in aidl.
- android::hidl::Status GetId(int *network_id_out) override;
- android::hidl::Status GetInterfaceName(
- std::string *ifname_out) override;
- android::hidl::Status RegisterCallback(
- const android::sp<fi::w1::wpa_supplicant::INetworkCallback>
- &callback) override;
- android::hidl::Status SetSSID(
- const std::vector<uint8_t> &ssid) override;
- android::hidl::Status SetBSSID(
- const std::vector<uint8_t> &bssid) override;
- android::hidl::Status SetScanSSID(bool enable) override;
- android::hidl::Status SetKeyMgmt(int32_t key_mgmt_mask) override;
- android::hidl::Status SetProto(int32_t proto_mask) override;
- android::hidl::Status SetAuthAlg(int32_t auth_alg_mask) override;
- android::hidl::Status SetGroupCipher(
- int32_t group_cipher_mask) override;
- android::hidl::Status SetPairwiseCipher(
- int32_t pairwise_cipher_mask) override;
- android::hidl::Status SetPskPassphrase(
- const std::string &psk) override;
- android::hidl::Status SetWepKey(
- int key_idx, const std::vector<uint8_t> &wep_key) override;
- android::hidl::Status SetWepTxKeyIdx(int32_t wep_tx_key_idx) override;
- android::hidl::Status SetRequirePMF(bool enable) override;
- android::hidl::Status SetEapMethod(int32_t method) override;
- android::hidl::Status SetEapPhase2Method(int32_t method) override;
- android::hidl::Status SetEapIdentity(
- const std::vector<uint8_t> &identity) override;
- android::hidl::Status SetEapAnonymousIdentity(
- const std::vector<uint8_t> &identity) override;
- android::hidl::Status SetEapPassword(
- const std::vector<uint8_t> &password) override;
- android::hidl::Status SetEapCACert(const std::string &path) override;
- android::hidl::Status SetEapCAPath(const std::string &path) override;
- android::hidl::Status SetEapClientCert(
- const std::string &path) override;
- android::hidl::Status SetEapPrivateKey(
- const std::string &path) override;
- android::hidl::Status SetEapSubjectMatch(
- const std::string &match) override;
- android::hidl::Status SetEapAltSubjectMatch(
- const std::string &match) override;
- android::hidl::Status SetEapEngine(bool enable) override;
- android::hidl::Status SetEapEngineID(const std::string &id) override;
- android::hidl::Status SetEapDomainSuffixMatch(
- const std::string &match) override;
- android::hidl::Status GetSSID(std::vector<uint8_t> *ssid) override;
- android::hidl::Status GetBSSID(std::vector<uint8_t> *bssid) override;
- android::hidl::Status GetScanSSID(bool *enable) override;
- android::hidl::Status GetKeyMgmt(int32_t *key_mgmt_mask) override;
- android::hidl::Status GetProto(int32_t *proto_mask) override;
- android::hidl::Status GetAuthAlg(int32_t *auth_alg_mask) override;
- android::hidl::Status GetGroupCipher(
- int32_t *group_cipher_mask) override;
- android::hidl::Status GetPairwiseCipher(
- int32_t *pairwise_cipher_mask) override;
- android::hidl::Status GetPskPassphrase(std::string *psk) override;
- android::hidl::Status GetWepKey(
- int key_idx, std::vector<uint8_t> *wep_key) override;
- android::hidl::Status GetWepTxKeyIdx(
- int32_t *wep_tx_key_idx) override;
- android::hidl::Status GetRequirePMF(bool *enable) override;
- android::hidl::Status Enable(bool no_connect) override;
- android::hidl::Status Disable() override;
- android::hidl::Status Select() override;
- android::hidl::Status SendNetworkResponse(
- int type, const std::string ¶m) override;
+ // Hidl methods exposed.
+ Return<void> getId(getId_cb _hidl_cb) override;
+ Return<void> getInterfaceName(getInterfaceName_cb _hidl_cb) override;
+ Return<void> registerCallback(
+ const sp<ISupplicantNetworkCallback>& callback,
+ registerCallback_cb _hidl_cb) override;
+ Return<void> setSsid(
+ const hidl_vec<uint8_t>& ssid, setSsid_cb _hidl_cb) override;
+ Return<void> setBssid(
+ const hidl_array<uint8_t, 6 /* 6 */>& bssid,
+ setBssid_cb _hidl_cb) override;
+ Return<void> setScanSsid(bool enable, setScanSsid_cb _hidl_cb) override;
+ Return<void> setKeyMgmt(
+ uint32_t key_mgmt_mask, setKeyMgmt_cb _hidl_cb) override;
+ Return<void> setProto(
+ uint32_t proto_mask, setProto_cb _hidl_cb) override;
+ Return<void> setAuthAlg(
+ uint32_t auth_alg_mask, setAuthAlg_cb _hidl_cb) override;
+ Return<void> setGroupCipher(
+ uint32_t group_cipher_mask, setGroupCipher_cb _hidl_cb) override;
+ Return<void> setPairwiseCipher(
+ uint32_t pairwise_cipher_mask,
+ setPairwiseCipher_cb _hidl_cb) override;
+ Return<void> setPskPassphrase(
+ const hidl_string& psk, setPskPassphrase_cb _hidl_cb) override;
+ Return<void> setWepKey(
+ uint32_t key_idx, const hidl_vec<uint8_t>& wep_key,
+ setWepKey_cb _hidl_cb) override;
+ Return<void> setWepTxKeyIdx(
+ uint32_t key_idx, setWepTxKeyIdx_cb _hidl_cb) override;
+ Return<void> setRequirePmf(
+ bool enable, setRequirePmf_cb _hidl_cb) override;
+ Return<void> setEapMethod(
+ ISupplicantNetwork::EapMethod method,
+ setEapMethod_cb _hidl_cb) override;
+ Return<void> setEapPhase2Method(
+ ISupplicantNetwork::EapPhase2Method method,
+ setEapPhase2Method_cb _hidl_cb) override;
+ Return<void> setEapIdentity(
+ const hidl_vec<uint8_t>& identity,
+ setEapIdentity_cb _hidl_cb) override;
+ Return<void> setEapAnonymousIdentity(
+ const hidl_vec<uint8_t>& identity,
+ setEapAnonymousIdentity_cb _hidl_cb) override;
+ Return<void> setEapPassword(
+ const hidl_vec<uint8_t>& password,
+ setEapPassword_cb _hidl_cb) override;
+ Return<void> setEapCACert(
+ const hidl_string& path, setEapCACert_cb _hidl_cb) override;
+ Return<void> setEapCAPath(
+ const hidl_string& path, setEapCAPath_cb _hidl_cb) override;
+ Return<void> setEapClientCert(
+ const hidl_string& path, setEapClientCert_cb _hidl_cb) override;
+ Return<void> setEapPrivateKey(
+ const hidl_string& path, setEapPrivateKey_cb _hidl_cb) override;
+ Return<void> setEapSubjectMatch(
+ const hidl_string& match, setEapSubjectMatch_cb _hidl_cb) override;
+ Return<void> setEapAltSubjectMatch(
+ const hidl_string& match,
+ setEapAltSubjectMatch_cb _hidl_cb) override;
+ Return<void> setEapEngine(
+ bool enable, setEapEngine_cb _hidl_cb) override;
+ Return<void> setEapEngineID(
+ const hidl_string& id, setEapEngineID_cb _hidl_cb) override;
+ Return<void> setEapDomainSuffixMatch(
+ const hidl_string& match,
+ setEapDomainSuffixMatch_cb _hidl_cb) override;
+ Return<void> getSsid(getSsid_cb _hidl_cb) override;
+ Return<void> getBssid(getBssid_cb _hidl_cb) override;
+ Return<void> getScanSsid(getScanSsid_cb _hidl_cb) override;
+ Return<void> getKeyMgmt(getKeyMgmt_cb _hidl_cb) override;
+ Return<void> getProto(getProto_cb _hidl_cb) override;
+ Return<void> getAuthAlg(getAuthAlg_cb _hidl_cb) override;
+ Return<void> getGroupCipher(getGroupCipher_cb _hidl_cb) override;
+ Return<void> getPairwiseCipher(getPairwiseCipher_cb _hidl_cb) override;
+ Return<void> getPskPassphrase(getPskPassphrase_cb _hidl_cb) override;
+ Return<void> getWepKey(
+ uint32_t key_idx, getWepKey_cb _hidl_cb) override;
+ Return<void> getWepTxKeyIdx(getWepTxKeyIdx_cb _hidl_cb) override;
+ Return<void> getRequirePmf(getRequirePmf_cb _hidl_cb) override;
+ Return<void> enable(bool no_connect, enable_cb _hidl_cb) override;
+ Return<void> disable(disable_cb _hidl_cb) override;
+ Return<void> select(select_cb _hidl_cb) override;
+ Return<void> sendNetworkEapSimGsmAuthResponse(
+ const ISupplicantNetwork::NetworkResponseEapSimGsmAuthParams&
+ params,
+ sendNetworkEapSimGsmAuthResponse_cb _hidl_cb) override;
+ Return<void> sendNetworkEapSimUmtsAuthResponse(
+ const ISupplicantNetwork::NetworkResponseEapSimUmtsAuthParams&
+ params,
+ sendNetworkEapSimUmtsAuthResponse_cb _hidl_cb) override;
+ Return<void> sendNetworkEapIdentityResponse(
+ const hidl_vec<uint8_t>& identity,
+ sendNetworkEapIdentityResponse_cb _hidl_cb) override;
private:
- struct wpa_ssid *retrieveNetworkPtr();
- struct wpa_supplicant *retrieveIfacePtr();
- int isPskPassphraseValid(const std::string &psk);
+ struct wpa_ssid* retrieveNetworkPtr();
+ struct wpa_supplicant* retrieveIfacePtr();
+ int isPskPassphraseValid(const android::hardware::hidl_string& psk);
void resetInternalStateAfterParamsUpdate();
- android::hidl::Status setStringFieldAndResetState(
- const char *value, uint8_t **to_update_field,
- const char *hexdump_prefix);
- android::hidl::Status setStringFieldAndResetState(
- const char *value, char **to_update_field,
- const char *hexdump_prefix);
- android::hidl::Status setStringKeyFieldAndResetState(
- const char *value, char **to_update_field,
- const char *hexdump_prefix);
- android::hidl::Status setByteArrayFieldAndResetState(
- const uint8_t *value, const size_t value_len,
- uint8_t **to_update_field, size_t *to_update_field_len,
- const char *hexdump_prefix);
- android::hidl::Status setByteArrayKeyFieldAndResetState(
- const uint8_t *value, const size_t value_len,
- uint8_t **to_update_field, size_t *to_update_field_len,
- const char *hexdump_prefix);
+ int setStringFieldAndResetState(
+ const char* value, uint8_t** to_update_field,
+ const char* hexdump_prefix);
+ int setStringFieldAndResetState(
+ const char* value, char** to_update_field,
+ const char* hexdump_prefix);
+ int setStringKeyFieldAndResetState(
+ const char* value, char** to_update_field,
+ const char* hexdump_prefix);
+ int setByteArrayFieldAndResetState(
+ const uint8_t* value, const size_t value_len,
+ uint8_t** to_update_field, size_t* to_update_field_len,
+ const char* hexdump_prefix);
+ int setByteArrayKeyFieldAndResetState(
+ const uint8_t* value, const size_t value_len,
+ uint8_t** to_update_field, size_t* to_update_field_len,
+ const char* hexdump_prefix);
- // Reference to the global wpa_struct. This is assumed to be valid for
- // the lifetime of the process.
- const struct wpa_global *wpa_global_;
+ // Reference to the global wpa_struct. This is assumed to be valid
+ // for the lifetime of the process.
+ const struct wpa_global* wpa_global_;
// Name of the iface this network belongs to.
const std::string ifname_;
// Id of the network this hidl object controls.
@@ -142,6 +174,11 @@
DISALLOW_COPY_AND_ASSIGN(Network);
};
-} // namespace wpa_supplicant_hidl
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
#endif // WPA_SUPPLICANT_HIDL_NETWORK_H
diff --git a/wpa_supplicant/hidl/supplicant.cpp b/wpa_supplicant/hidl/supplicant.cpp
index 3ff514e..b9f6ce2 100644
--- a/wpa_supplicant/hidl/supplicant.cpp
+++ b/wpa_supplicant/hidl/supplicant.cpp
@@ -7,252 +7,149 @@
* See README for more details.
*/
-#include "supplicant.h"
#include "hidl_manager.h"
-#include "../src/utils/wpa_debug.h"
+#include "hidl_return_macros.h"
+#include "supplicant.h"
-namespace wpa_supplicant_hidl {
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
-Supplicant::Supplicant(struct wpa_global *global) : wpa_global_(global) {}
-android::hidl::Status Supplicant::CreateInterface(
- const fi::w1::wpa_supplicant::ParcelableIfaceParams ¶ms,
- android::sp<fi::w1::wpa_supplicant::IIface> *iface_object_out)
+// These are hardcoded for android.
+const char Supplicant::kDriverName[] = "nl80211";
+const char Supplicant::kConfigFilePath[] =
+ "/data/misc/wifi/wpa_supplicant.conf";
+
+Supplicant::Supplicant(struct wpa_global* global) : wpa_global_(global) {}
+Return<void> Supplicant::createInterface(
+ const hidl_string& ifname, createInterface_cb _hidl_cb)
{
- /* Check if required Ifname argument is missing */
- if (params.ifname_.isEmpty()) {
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- "Ifname missing in params.");
+ android::sp<ISupplicantIface> iface;
+
+ // Check if required |ifname| argument is empty.
+ if (ifname.size() == 0) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID, iface);
}
- /*
- * Try to get the wpa_supplicant record for this iface, return
- * an error if we already control it.
- */
- if (wpa_supplicant_get_iface(wpa_global_, params.ifname_.string()) !=
- NULL) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_IFACE_EXISTS,
- "wpa_supplicant already controls this interface.");
+ // Try to get the wpa_supplicant record for this iface, return
+ // an error if we already control it.
+ if (wpa_supplicant_get_iface(wpa_global_, ifname.c_str()) != NULL) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_EXISTS, iface);
}
- android::hidl::Status status;
- struct wpa_supplicant *wpa_s = NULL;
- struct wpa_interface iface;
-
- os_memset(&iface, 0, sizeof(iface));
- iface.driver = os_strdup(params.driver_.string());
- iface.ifname = os_strdup(params.ifname_.string());
- iface.confname = os_strdup(params.config_file_.string());
- iface.bridge_ifname = os_strdup(params.bridge_ifname_.string());
- /* Otherwise, have wpa_supplicant attach to it. */
- wpa_s = wpa_supplicant_add_iface(wpa_global_, &iface, NULL);
- /* The supplicant core creates a corresponding hidl object via
- * HidlManager when |wpa_supplicant_add_iface| is called. */
+ // Otherwise, have wpa_supplicant attach to it.
+ struct wpa_supplicant* wpa_s = NULL;
+ struct wpa_interface iface_params;
+ os_memset(&iface_params, 0, sizeof(iface));
+ iface_params.ifname = ifname.c_str();
+ iface_params.confname = kConfigFilePath;
+ iface_params.driver = kDriverName;
+ wpa_s = wpa_supplicant_add_iface(wpa_global_, &iface_params, NULL);
if (!wpa_s) {
- status = android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant couldn't grab this interface.");
- } else {
- HidlManager *hidl_manager = HidlManager::getInstance();
-
- if (!hidl_manager ||
- hidl_manager->getIfaceHidlObjectByIfname(
- wpa_s->ifname, iface_object_out)) {
- status =
- android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant encountered a hidl error.");
- } else {
- status = android::hidl::Status::ok();
- }
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, iface);
}
- os_free((void *)iface.driver);
- os_free((void *)iface.ifname);
- os_free((void *)iface.confname);
- os_free((void *)iface.bridge_ifname);
- return status;
+ // The supplicant core creates a corresponding hidl object via
+ // HidlManager when |wpa_supplicant_add_iface| is called.
+ HidlManager* hidl_manager = HidlManager::getInstance();
+ if (!hidl_manager ||
+ hidl_manager->getIfaceHidlObjectByIfname(wpa_s->ifname, &iface)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, iface);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, iface);
}
-android::hidl::Status Supplicant::RemoveInterface(const std::string &ifname)
+Return<void> Supplicant::removeInterface(
+ const hidl_string& ifname, removeInterface_cb _hidl_cb)
{
- struct wpa_supplicant *wpa_s;
+ struct wpa_supplicant* wpa_s;
wpa_s = wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
if (!wpa_s) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_IFACE_UNKNOWN,
- "wpa_supplicant does not control this interface.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_UNKNOWN);
}
if (wpa_supplicant_remove_iface(wpa_global_, wpa_s, 0)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant couldn't remove this interface.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-android::hidl::Status Supplicant::GetInterface(
- const std::string &ifname,
- android::sp<fi::w1::wpa_supplicant::IIface> *iface_object_out)
+Return<void> Supplicant::getInterface(
+ const hidl_string& ifname, getInterface_cb _hidl_cb)
{
- struct wpa_supplicant *wpa_s;
+ android::sp<ISupplicantIface> iface;
- wpa_s = wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
+ struct wpa_supplicant* wpa_s =
+ wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
if (!wpa_s) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_IFACE_UNKNOWN,
- "wpa_supplicant does not control this interface.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_UNKNOWN, iface);
}
- HidlManager *hidl_manager = HidlManager::getInstance();
+ HidlManager* hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
- hidl_manager->getIfaceHidlObjectByIfname(
- wpa_s->ifname, iface_object_out)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant encountered a hidl error.");
+ hidl_manager->getIfaceHidlObjectByIfname(wpa_s->ifname, &iface)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, iface);
}
- return android::hidl::Status::ok();
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, iface);
}
-android::hidl::Status Supplicant::SetDebugParams(
- int level, bool show_timestamp, bool show_keys)
+Return<void> Supplicant::listInterfaces(listInterfaces_cb _hidl_cb)
{
- int internal_level;
- if (convertDebugLevelToInternalLevel(level, &internal_level)) {
- const std::string error_msg =
- "invalid debug level: " + std::to_string(level);
- return android::hidl::Status::fromExceptionCode(
- android::hidl::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
+ std::vector<hidl_string> ifnames;
+ for (struct wpa_supplicant* wpa_s = wpa_global_->ifaces; wpa_s;
+ wpa_s = wpa_s->next) {
+ ifnames.emplace_back(wpa_s->ifname);
}
- if (wpa_supplicant_set_debug_params(
-<<<<<<< 390ba2881ef621db480848b7e50b93d61542206a:wpa_supplicant/binder/supplicant.cpp
- wpa_global_, internal_level, show_timestamp, show_keys)) {
- return android::binder::Status::fromServiceSpecificError(
-=======
- wpa_global_, level, show_timestamp, show_keys)) {
- return android::hidl::Status::fromServiceSpecificError(
->>>>>>> wpa_supplicant: HIDL implementation (1/2):wpa_supplicant/hidl/supplicant.cpp
- ERROR_GENERIC,
- "wpa_supplicant could not set debug params.");
- }
- return android::hidl::Status::ok();
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifnames);
}
-android::hidl::Status Supplicant::GetDebugLevel(int *level_out)
+Return<void> Supplicant::registerCallback(
+ const sp<ISupplicantCallback>& callback, registerCallback_cb _hidl_cb)
{
-<<<<<<< 390ba2881ef621db480848b7e50b93d61542206a:wpa_supplicant/binder/supplicant.cpp
- if (convertDebugLevelToExternalLevel(wpa_debug_level, level_out)) {
- const std::string error_msg =
- "invalid debug level: " + std::to_string(wpa_debug_level);
- return android::binder::Status::fromExceptionCode(
- android::binder::Status::EX_ILLEGAL_ARGUMENT,
- error_msg.c_str());
- }
- return android::binder::Status::ok();
-=======
- *level_out = wpa_debug_level;
- return android::hidl::Status::ok();
->>>>>>> wpa_supplicant: HIDL implementation (1/2):wpa_supplicant/hidl/supplicant.cpp
-}
-
-android::hidl::Status Supplicant::GetDebugShowTimestamp(
- bool *show_timestamp_out)
-{
- *show_timestamp_out = wpa_debug_timestamp ? true : false;
- return android::hidl::Status::ok();
-}
-
-android::hidl::Status Supplicant::GetDebugShowKeys(bool *show_keys_out)
-{
- *show_keys_out = wpa_debug_show_keys ? true : false;
- return android::hidl::Status::ok();
-}
-
-android::hidl::Status Supplicant::RegisterCallback(
- const android::sp<fi::w1::wpa_supplicant::ISupplicantCallback> &callback)
-{
- HidlManager *hidl_manager = HidlManager::getInstance();
+ HidlManager* hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
hidl_manager->addSupplicantCallbackHidlObject(callback)) {
- return android::hidl::Status::fromServiceSpecificError(
- ERROR_GENERIC,
- "wpa_supplicant encountered a hidl error.");
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
- return android::hidl::Status::ok();
-}
-<<<<<<< 390ba2881ef621db480848b7e50b93d61542206a:wpa_supplicant/binder/supplicant.cpp
-/**
- * Helper function to convert the debug level parameter from the binder
- * interface values to internal values.
- */
-int Supplicant::convertDebugLevelToInternalLevel(
- int external_level, int *internal_level)
-{
- switch (external_level) {
- case DEBUG_LEVEL_EXCESSIVE:
- *internal_level = MSG_EXCESSIVE;
- return 0;
- case DEBUG_LEVEL_MSGDUMP:
- *internal_level = MSG_MSGDUMP;
- return 0;
- case DEBUG_LEVEL_DEBUG:
- *internal_level = MSG_DEBUG;
- return 0;
- case DEBUG_LEVEL_INFO:
- *internal_level = MSG_INFO;
- return 0;
- case DEBUG_LEVEL_WARNING:
- *internal_level = MSG_WARNING;
- return 0;
- case DEBUG_LEVEL_ERROR:
- *internal_level = MSG_ERROR;
- return 0;
- default:
- wpa_printf(
- MSG_ERROR, "Invalid external log level: %d",
- external_level);
- return 1;
- }
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-/**
- * Helper function to convert the debug level parameter from the internal values
- * to binder interface values.
- */
-int Supplicant::convertDebugLevelToExternalLevel(
- int internal_level, int *external_level)
+Return<void> Supplicant::setDebugParams(
+ ISupplicant::DebugLevel level, bool show_timestamp, bool show_keys,
+ setDebugParams_cb _hidl_cb)
{
- switch (internal_level) {
- case MSG_EXCESSIVE:
- *external_level = DEBUG_LEVEL_EXCESSIVE;
- return 0;
- case MSG_MSGDUMP:
- *external_level = DEBUG_LEVEL_MSGDUMP;
- return 0;
- case MSG_DEBUG:
- *external_level = DEBUG_LEVEL_DEBUG;
- return 0;
- case MSG_INFO:
- *external_level = DEBUG_LEVEL_INFO;
- return 0;
- case MSG_WARNING:
- *external_level = DEBUG_LEVEL_WARNING;
- return 0;
- case MSG_ERROR:
- *external_level = DEBUG_LEVEL_ERROR;
- return 0;
- default:
- wpa_printf(
- MSG_ERROR, "Invalid internal log level: %d",
- internal_level);
- return 1;
+ if (wpa_supplicant_set_debug_params(
+ wpa_global_, static_cast<uint32_t>(level), show_timestamp,
+ show_keys)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-} /* namespace wpa_supplicant_binder */
-=======
-} /* namespace wpa_supplicant_hidl */
->>>>>>> wpa_supplicant: HIDL implementation (1/2):wpa_supplicant/hidl/supplicant.cpp
+
+Return<ISupplicant::DebugLevel> Supplicant::getDebugLevel()
+{
+ return (ISupplicant::DebugLevel)wpa_debug_level;
+}
+
+Return<bool> Supplicant::isDebugShowTimestampEnabled()
+{
+ return (wpa_debug_timestamp ? true : false);
+}
+
+Return<bool> Supplicant::isDebugShowKeysEnabled()
+{
+ return (wpa_debug_show_keys ? true : false);
+}
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
diff --git a/wpa_supplicant/hidl/supplicant.h b/wpa_supplicant/hidl/supplicant.h
index 9805289..cad4052 100644
--- a/wpa_supplicant/hidl/supplicant.h
+++ b/wpa_supplicant/hidl/supplicant.h
@@ -12,65 +12,68 @@
#include <android-base/macros.h>
-#include "fi/w1/wpa_supplicant/BnSupplicant.h"
-#include "fi/w1/wpa_supplicant/IIface.h"
-#include "fi/w1/wpa_supplicant/ISupplicantCallback.h"
+#include <android/hardware/wifi/supplicant/1.0/ISupplicant.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantIface.h>
extern "C" {
#include "utils/common.h"
#include "utils/includes.h"
-#include "../wpa_supplicant_i.h"
+#include "utils/wpa_debug.h"
+#include "wpa_supplicant_i.h"
}
-namespace wpa_supplicant_hidl {
-
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
/**
* Implementation of the supplicant hidl object. This hidl
* object is used core for global control operations on
* wpa_supplicant.
*/
-class Supplicant : public fi::w1::wpa_supplicant::BnSupplicant
+class Supplicant : public android::hardware::wifi::supplicant::V1_0::ISupplicant
{
public:
- Supplicant(struct wpa_global *global);
+ Supplicant(struct wpa_global* global);
~Supplicant() override = default;
- // Hidl methods exposed in aidl.
- android::hidl::Status CreateInterface(
- const fi::w1::wpa_supplicant::ParcelableIfaceParams ¶ms,
- android::sp<fi::w1::wpa_supplicant::IIface> *iface_object_out)
- override;
- android::hidl::Status RemoveInterface(
- const std::string &ifname) override;
- android::hidl::Status GetInterface(
- const std::string &ifname,
- android::sp<fi::w1::wpa_supplicant::IIface> *iface_object_out)
- override;
- android::hidl::Status SetDebugParams(
- int level, bool show_timestamp, bool show_keys) override;
- android::hidl::Status GetDebugLevel(int *level_out) override;
- android::hidl::Status GetDebugShowTimestamp(
- bool *show_timestamp_out) override;
- android::hidl::Status GetDebugShowKeys(bool *show_keys_out) override;
- android::hidl::Status RegisterCallback(
- const android::sp<fi::w1::wpa_supplicant::ISupplicantCallback>
- &callback) override;
+ // Hidl methods exposed.
+ Return<void> createInterface(
+ const hidl_string& ifname, createInterface_cb _hidl_cb) override;
+ Return<void> removeInterface(
+ const hidl_string& ifname, removeInterface_cb _hidl_cb) override;
+ Return<void> getInterface(
+ const hidl_string& ifname, getInterface_cb _hidl_cb) override;
+ Return<void> listInterfaces(listInterfaces_cb _hidl_cb) override;
+ Return<void> registerCallback(
+ const sp<ISupplicantCallback>& callback,
+ registerCallback_cb _hidl_cb) override;
+ Return<void> setDebugParams(
+ ISupplicant::DebugLevel level, bool show_timestamp, bool show_keys,
+ setDebugParams_cb _hidl_cb) override;
+ Return<ISupplicant::DebugLevel> getDebugLevel() override;
+ Return<bool> isDebugShowTimestampEnabled() override;
+ Return<bool> isDebugShowKeysEnabled() override;
private:
- int convertDebugLevelToInternalLevel(
- int external_level, int *internal_level);
- int convertDebugLevelToExternalLevel(
- int internal_level, int *external_level);
-
- /* Raw pointer to the global structure maintained by the core. */
- struct wpa_global *wpa_global_;
- /* All the callback objects registered by the clients. */
- std::vector<android::sp<fi::w1::wpa_supplicant::ISupplicantCallback>>
- callbacks_;
+ // Raw pointer to the global structure maintained by the core.
+ struct wpa_global* wpa_global_;
+ // Driver name to be used for creating interfaces.
+ static const char kDriverName[];
+ // wpa_supplicant.conf file location on the device.
+ static const char kConfigFilePath[];
DISALLOW_COPY_AND_ASSIGN(Supplicant);
};
-} /* namespace wpa_supplicant_hidl */
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
-#endif /* WPA_SUPPLICANT_HIDL_SUPPLICANT_H */
+#endif // WPA_SUPPLICANT_HIDL_SUPPLICANT_H
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index c801ccf..282ef66 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2858,95 +2858,6 @@
}
/**
- * wpa_supplicant_add_network - Add a new network
- * @wpa_s: wpa_supplicant structure for a network interface
- * Returns: The new network configuration or %NULL if operation failed
- *
- * This function performs the following operations:
- * 1. Adds a new network.
- * 2. Send network addition notification.
- * 3. Marks the network disabled.
- * 4. Set network default parameters.
- */
-struct wpa_ssid * wpa_supplicant_add_network(struct wpa_supplicant *wpa_s)
-{
- struct wpa_ssid *ssid;
-
- ssid = wpa_config_add_network(wpa_s->conf);
- if (!ssid)
- return NULL;
- wpas_notify_network_added(wpa_s, ssid);
- ssid->disabled = 1;
- wpa_config_set_network_defaults(ssid);
-
- return ssid;
-}
-
-
-/**
- * wpa_supplicant_remove_network - Remove a configured network based on id
- * @wpa_s: wpa_supplicant structure for a network interface
- * @id: Unique network id to search for
- * Returns: 0 on success, or -1 if the network was not found, -2 if the network
- * could not be removed
- *
- * This function performs the following operations:
- * 1. Removes the network.
- * 2. Send network removal notification.
- * 3. Update internal state machines.
- * 4. Stop any running sched scans.
- */
-int wpa_supplicant_remove_network(struct wpa_supplicant *wpa_s, int id)
-{
- struct wpa_ssid *ssid;
- int was_disabled;
-
- ssid = wpa_config_get_network(wpa_s->conf, id);
- if (!ssid)
- return -1;
- wpas_notify_network_removed(wpa_s, ssid);
-
- if (wpa_s->last_ssid == ssid)
- wpa_s->last_ssid = NULL;
-
- if (ssid == wpa_s->current_ssid || !wpa_s->current_ssid) {
-#ifdef CONFIG_SME
- wpa_s->sme.prev_bssid_set = 0;
-#endif /* CONFIG_SME */
- /*
- * Invalidate the EAP session cache if the current or
- * previously used network is removed.
- */
- eapol_sm_invalidate_cached_session(wpa_s->eapol);
- }
-
- if (ssid == wpa_s->current_ssid) {
- wpa_sm_set_config(wpa_s->wpa, NULL);
- eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
-
- if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
- wpa_s->own_disconnect_req = 1;
- wpa_supplicant_deauthenticate(wpa_s,
- WLAN_REASON_DEAUTH_LEAVING);
- }
-
- was_disabled = ssid->disabled;
-
- if (wpa_config_remove_network(wpa_s->conf, id) < 0)
- return -2;
-
- if (!was_disabled && wpa_s->sched_scanning) {
- wpa_printf(MSG_DEBUG,
- "Stop ongoing sched_scan to remove network from filters");
- wpa_supplicant_cancel_sched_scan(wpa_s);
- wpa_supplicant_req_scan(wpa_s, 0, 0);
- }
-
- return 0;
-}
-
-
-/**
* wpa_supplicant_enable_network - Mark a configured network as enabled
* @wpa_s: wpa_supplicant structure for a network interface
* @ssid: wpa_ssid structure for a configured network or %NULL
@@ -6260,26 +6171,6 @@
eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
}
-/**
- * wpas_request_disconnection - Request disconnection
- * @wpa_s: Pointer to the network interface
- *
- * This function is used to request disconnection from the currently connected
- * network. This will stop any ongoing scans and initiate deauthentication.
- */
-void wpas_request_disconnection(struct wpa_supplicant *wpa_s)
-{
-#ifdef CONFIG_SME
- wpa_s->sme.prev_bssid_set = 0;
-#endif /* CONFIG_SME */
- wpa_s->reassociate = 0;
- wpa_s->disconnected = 1;
- wpa_supplicant_cancel_sched_scan(wpa_s);
- wpa_supplicant_cancel_scan(wpa_s);
- wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
- eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
-}
-
void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title,
struct wpa_used_freq_data *freqs_data,