Merge changes from topic 'supplicant_hidl_iface_create_remove'
* changes:
wpa_supplicant: Send P2P mgmt iface add/remove notifications
wpa_supplicant: Remove create/remove iface methods from HIDL
wpa_supplicant: Add support for 2 iface types
wpa_supplicant: Add P2P |Iface| & |Network| classes
wpa_supplicant: Rename |Iface| & |INetwork|
diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk
index 5a3cd29..1a25d08 100644
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
@@ -1669,8 +1669,10 @@
LOCAL_SRC_FILES := \
hidl/hidl.cpp \
hidl/hidl_manager.cpp \
- hidl/iface.cpp \
- hidl/network.cpp \
+ hidl/p2p_iface.cpp \
+ hidl/p2p_network.cpp \
+ hidl/sta_iface.cpp \
+ hidl/sta_network.cpp \
hidl/supplicant.cpp
LOCAL_SHARED_LIBRARIES := \
android.hardware.wifi.supplicant@1.0 \
diff --git a/wpa_supplicant/hidl/hidl_manager.cpp b/wpa_supplicant/hidl/hidl_manager.cpp
index 372b221..c5705d1 100644
--- a/wpa_supplicant/hidl/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/hidl_manager.cpp
@@ -11,11 +11,282 @@
#include "hidl_manager.h"
-extern "C" {
-#include "utils/common.h"
-#include "utils/includes.h"
+namespace {
+/**
+ * Check if the provided |wpa_supplicant| structure represents a P2P iface or
+ * not.
+ */
+constexpr bool isP2pIface(const struct wpa_supplicant *wpa_s)
+{
+ return (wpa_s->global->p2p_init_wpa_s == wpa_s);
}
+/**
+ * Creates a unique key for the network using the provided |ifname| and
+ * |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.
+ * @param network_id ID of the corresponding network.
+ */
+const std::string getNetworkObjectMapKey(
+ const std::string &ifname, int network_id)
+{
+ return ifname + "_" + std::to_string(network_id);
+}
+
+/**
+ * Add callback to the corresponding list after linking to death on the
+ * corresponding hidl object reference.
+ */
+template <class CallbackType>
+int registerForDeathAndAddCallbackHidlObjectToList(
+ const android::sp<CallbackType> &callback,
+ const std::function<void(const android::sp<CallbackType> &)>
+ &on_hidl_died_fctor,
+ std::vector<android::sp<CallbackType>> &callback_list)
+{
+#if 0 // TODO(b/31632518): HIDL object death notifications.
+ auto death_notifier = new CallbackObjectDeathNotifier<CallbackType>(
+ callback, on_hidl_died_fctor);
+ // Use the |callback.get()| as cookie so that we don't need to
+ // 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!
+ if (android::hardware::IInterface::asBinder(callback)->linkToDeath(
+ death_notifier, callback.get()) != android::OK) {
+ wpa_printf(
+ MSG_ERROR,
+ "Error registering for death notification for "
+ "supplicant callback object");
+ callback_list.erase(
+ std::remove(
+ callback_list.begin(), callback_list.end(), callback),
+ callback_list.end());
+ return 1;
+ }
+#endif // TODO(b/31632518): HIDL object death notifications.
+ callback_list.push_back(callback);
+ return 0;
+}
+
+template <class ObjectType>
+int addHidlObjectToMap(
+ const std::string &key, const android::sp<ObjectType> object,
+ std::map<const std::string, android::sp<ObjectType>> &object_map)
+{
+ // Return failure if we already have an object for that |key|.
+ if (object_map.find(key) != object_map.end())
+ return 1;
+ object_map[key] = object;
+ if (!object_map[key].get())
+ return 1;
+ return 0;
+}
+
+template <class ObjectType>
+int removeHidlObjectFromMap(
+ const std::string &key,
+ std::map<const std::string, android::sp<ObjectType>> &object_map)
+{
+ // Return failure if we dont have an object for that |key|.
+ if (object_map.find(key) == object_map.end())
+ return 1;
+ object_map.erase(key);
+ return 0;
+}
+
+template <class CallbackType>
+int addIfaceCallbackHidlObjectToMap(
+ const std::string &ifname, const android::sp<CallbackType> &callback,
+ const std::function<void(const android::sp<CallbackType> &)>
+ &on_hidl_died_fctor,
+ std::map<const std::string, std::vector<android::sp<CallbackType>>>
+ &callbacks_map)
+{
+ if (ifname.empty())
+ return 1;
+
+ auto iface_callback_map_iter = callbacks_map.find(ifname);
+ if (iface_callback_map_iter == callbacks_map.end())
+ return 1;
+ auto &iface_callback_list = iface_callback_map_iter->second;
+
+ // Register for death notification before we add it to our list.
+ return registerForDeathAndAddCallbackHidlObjectToList<CallbackType>(
+ callback, on_hidl_died_fctor, iface_callback_list);
+}
+
+template <class CallbackType>
+int addNetworkCallbackHidlObjectToMap(
+ const std::string &ifname, int network_id,
+ const android::sp<CallbackType> &callback,
+ const std::function<void(const android::sp<CallbackType> &)>
+ &on_hidl_died_fctor,
+ std::map<const std::string, std::vector<android::sp<CallbackType>>>
+ &callbacks_map)
+{
+ if (ifname.empty() || network_id < 0)
+ return 1;
+
+ // Generate the key to be used to lookup the network.
+ const std::string network_key =
+ getNetworkObjectMapKey(ifname, network_id);
+ auto network_callback_map_iter = callbacks_map.find(network_key);
+ if (network_callback_map_iter == callbacks_map.end())
+ return 1;
+ auto &network_callback_list = network_callback_map_iter->second;
+
+ // Register for death notification before we add it to our list.
+ return registerForDeathAndAddCallbackHidlObjectToList<CallbackType>(
+ callback, on_hidl_died_fctor, network_callback_list);
+}
+
+template <class CallbackType>
+int removeAllIfaceCallbackHidlObjectsFromMap(
+ const std::string &ifname,
+ std::map<const std::string, std::vector<android::sp<CallbackType>>>
+ &callbacks_map)
+{
+ auto iface_callback_map_iter = callbacks_map.find(ifname);
+ if (iface_callback_map_iter == callbacks_map.end())
+ return 1;
+#if 0 // TODO(b/31632518): HIDL object death notifications.
+ const auto &iface_callback_list = iface_callback_map_iter->second;
+ for (const auto &callback : iface_callback_list) {
+ 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.
+ callbacks_map.erase(iface_callback_map_iter);
+ return 0;
+}
+
+template <class CallbackType>
+int removeAllNetworkCallbackHidlObjectsFromMap(
+ const std::string &network_key,
+ std::map<const std::string, std::vector<android::sp<CallbackType>>>
+ &callbacks_map)
+{
+ auto network_callback_map_iter = callbacks_map.find(network_key);
+ if (network_callback_map_iter == callbacks_map.end())
+ return 1;
+#if 0 // TODO(b/31632518): HIDL object death notifications.
+ const auto &network_callback_list = network_callback_map_iter->second;
+ for (const auto &callback : network_callback_list) {
+ if (android::hardware::IInterface::asBinder(callback)
+ ->unlinkToDeath(nullptr, callback.get()) !=
+ android::OK) {
+ wpa_printf(
+ MSG_ERROR,
+ "Error deregistering for death "
+ "notification for "
+ "network callback object");
+ }
+ }
+#endif // TODO(b/31632518): HIDL object death notifications.
+ callbacks_map.erase(network_callback_map_iter);
+ return 0;
+}
+
+template <class CallbackType>
+void removeIfaceCallbackHidlObjectFromMap(
+ const std::string &ifname, const android::sp<CallbackType> &callback,
+ std::map<const std::string, std::vector<android::sp<CallbackType>>>
+ &callbacks_map)
+{
+ if (ifname.empty())
+ return;
+
+ auto iface_callback_map_iter = callbacks_map.find(ifname);
+ if (iface_callback_map_iter == callbacks_map.end())
+ return;
+
+ auto &iface_callback_list = iface_callback_map_iter->second;
+ iface_callback_list.erase(
+ std::remove(
+ iface_callback_list.begin(), iface_callback_list.end(),
+ callback),
+ iface_callback_list.end());
+}
+
+template <class CallbackType>
+void removeNetworkCallbackHidlObjectFromMap(
+ const std::string &ifname, int network_id,
+ const android::sp<CallbackType> &callback,
+ std::map<const std::string, std::vector<android::sp<CallbackType>>>
+ &callbacks_map)
+{
+ if (ifname.empty() || network_id < 0)
+ return;
+
+ // Generate the key to be used to lookup the network.
+ const std::string network_key =
+ getNetworkObjectMapKey(ifname, network_id);
+
+ auto network_callback_map_iter = callbacks_map.find(network_key);
+ if (network_callback_map_iter == callbacks_map.end())
+ return;
+
+ auto &network_callback_list = network_callback_map_iter->second;
+ network_callback_list.erase(
+ std::remove(
+ network_callback_list.begin(), network_callback_list.end(),
+ callback),
+ network_callback_list.end());
+}
+
+template <class CallbackType>
+void callWithEachIfaceCallback(
+ const std::string &ifname,
+ const std::function<
+ android::hardware::Return<void>(android::sp<CallbackType>)> &method,
+ const std::map<const std::string, std::vector<android::sp<CallbackType>>>
+ &callbacks_map)
+{
+ if (ifname.empty())
+ return;
+
+ auto iface_callback_map_iter = callbacks_map.find(ifname);
+ if (iface_callback_map_iter == callbacks_map.end())
+ return;
+ const auto &iface_callback_list = iface_callback_map_iter->second;
+ for (const auto &callback : iface_callback_list) {
+ method(callback);
+ }
+}
+
+template <class CallbackType>
+void callWithEachNetworkCallback(
+ const std::string &ifname, int network_id,
+ const std::function<
+ android::hardware::Return<void>(android::sp<CallbackType>)> &method,
+ const std::map<const std::string, std::vector<android::sp<CallbackType>>>
+ &callbacks_map)
+{
+ if (ifname.empty() || network_id < 0)
+ return;
+
+ // Generate the key to be used to lookup the network.
+ const std::string network_key =
+ getNetworkObjectMapKey(ifname, network_id);
+ auto network_callback_map_iter = callbacks_map.find(network_key);
+ if (network_callback_map_iter == callbacks_map.end())
+ return;
+ const auto &network_callback_list = network_callback_map_iter->second;
+ for (const auto &callback : network_callback_list) {
+ method(callback);
+ }
+}
+} // namespace
+
namespace android {
namespace hardware {
namespace wifi {
@@ -66,17 +337,21 @@
// Using the corresponding ifname as key to our object map.
const std::string ifname(wpa_s->ifname);
- // Return failure if we already have an object for that |ifname|.
- if (iface_object_map_.find(ifname) != iface_object_map_.end())
- return 1;
-
- iface_object_map_[ifname] = new Iface(wpa_s->global, wpa_s->ifname);
- if (!iface_object_map_[ifname].get())
- return 1;
-
- // Initialize the vector of callbacks for this object.
- iface_callbacks_map_[ifname] =
- std::vector<android::sp<ISupplicantIfaceCallback>>();
+ if (isP2pIface(wpa_s)) {
+ if (addHidlObjectToMap<P2pIface>(
+ ifname, new P2pIface(wpa_s->global, wpa_s->ifname),
+ p2p_iface_object_map_))
+ return 1;
+ p2p_iface_callbacks_map_[ifname] =
+ std::vector<android::sp<ISupplicantP2pIfaceCallback>>();
+ } else {
+ if (addHidlObjectToMap<StaIface>(
+ ifname, new StaIface(wpa_s->global, wpa_s->ifname),
+ sta_iface_object_map_))
+ return 1;
+ sta_iface_callbacks_map_[ifname] =
+ std::vector<android::sp<ISupplicantStaIfaceCallback>>();
+ }
// Invoke the |onInterfaceCreated| method on all registered callbacks.
callWithEachSupplicantCallback(std::bind(
@@ -99,30 +374,21 @@
const std::string ifname(wpa_s->ifname);
- if (iface_object_map_.find(ifname) == iface_object_map_.end())
- return 1;
-
- // Delete the corresponding iface object from our map.
- iface_object_map_.erase(ifname);
-
- // Delete all callbacks registered for this object.
- auto iface_callback_map_iter = iface_callbacks_map_.find(ifname);
- 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::hardware::IInterface::asBinder(callback)
- ->unlinkToDeath(nullptr, callback.get()) !=
- android::OK) {
- wpa_printf(
- MSG_ERROR,
- "Error deregistering for death notification for "
- "iface callback object");
+ if (isP2pIface(wpa_s)) {
+ if (removeHidlObjectFromMap(ifname, p2p_iface_object_map_))
+ return 1;
+ if (removeAllIfaceCallbackHidlObjectsFromMap(
+ ifname, p2p_iface_callbacks_map_)) {
+ return 1;
+ }
+ } else {
+ if (removeHidlObjectFromMap(ifname, sta_iface_object_map_))
+ return 1;
+ if (removeAllIfaceCallbackHidlObjectsFromMap(
+ ifname, sta_iface_callbacks_map_)) {
+ return 1;
}
}
-#endif // TODO(b/31632518): HIDL object death notifications.
- iface_callbacks_map_.erase(iface_callback_map_iter);
// Invoke the |onInterfaceRemoved| method on all registered callbacks.
callWithEachSupplicantCallback(std::bind(
@@ -150,23 +416,37 @@
const std::string network_key =
getNetworkObjectMapKey(wpa_s->ifname, ssid->id);
- if (network_object_map_.find(network_key) != network_object_map_.end())
- return 1;
-
- network_object_map_[network_key] =
- new Network(wpa_s->global, wpa_s->ifname, ssid->id);
- if (!network_object_map_[network_key].get())
- return 1;
-
- // Initialize the vector of callbacks for this object.
- network_callbacks_map_[network_key] =
- std::vector<android::sp<ISupplicantNetworkCallback>>();
-
- // Invoke the |onNetworkAdded| method on all registered callbacks.
- callWithEachIfaceCallback(
- wpa_s->ifname, std::bind(
- &ISupplicantIfaceCallback::onNetworkAdded,
- std::placeholders::_1, ssid->id));
+ if (isP2pIface(wpa_s)) {
+ if (addHidlObjectToMap<P2pNetwork>(
+ network_key,
+ new P2pNetwork(wpa_s->global, wpa_s->ifname, ssid->id),
+ p2p_network_object_map_))
+ return 1;
+ p2p_network_callbacks_map_[network_key] =
+ std::vector<android::sp<ISupplicantP2pNetworkCallback>>();
+ // Invoke the |onNetworkAdded| method on all registered
+ // callbacks.
+ callWithEachP2pIfaceCallback(
+ wpa_s->ifname,
+ std::bind(
+ &ISupplicantP2pIfaceCallback::onNetworkAdded,
+ std::placeholders::_1, ssid->id));
+ } else {
+ if (addHidlObjectToMap<StaNetwork>(
+ network_key,
+ new StaNetwork(wpa_s->global, wpa_s->ifname, ssid->id),
+ sta_network_object_map_))
+ return 1;
+ sta_network_callbacks_map_[network_key] =
+ std::vector<android::sp<ISupplicantStaNetworkCallback>>();
+ // Invoke the |onNetworkAdded| method on all registered
+ // callbacks.
+ callWithEachStaIfaceCallback(
+ wpa_s->ifname,
+ std::bind(
+ &ISupplicantStaIfaceCallback::onNetworkAdded,
+ std::placeholders::_1, ssid->id));
+ }
return 0;
}
@@ -189,38 +469,35 @@
const std::string network_key =
getNetworkObjectMapKey(wpa_s->ifname, ssid->id);
- if (network_object_map_.find(network_key) == network_object_map_.end())
- return 1;
+ if (isP2pIface(wpa_s)) {
+ if (removeHidlObjectFromMap(network_key, p2p_iface_object_map_))
+ return 1;
+ if (removeAllNetworkCallbackHidlObjectsFromMap(
+ network_key, p2p_network_callbacks_map_))
+ return 1;
- // Delete the corresponding network object from our map.
- network_object_map_.erase(network_key);
+ // Invoke the |onNetworkRemoved| method on all registered
+ // callbacks.
+ callWithEachP2pIfaceCallback(
+ wpa_s->ifname,
+ std::bind(
+ &ISupplicantP2pIfaceCallback::onNetworkRemoved,
+ std::placeholders::_1, ssid->id));
+ } else {
+ if (removeHidlObjectFromMap(network_key, sta_iface_object_map_))
+ return 1;
+ if (removeAllNetworkCallbackHidlObjectsFromMap(
+ network_key, sta_network_callbacks_map_))
+ return 1;
- // Delete all callbacks registered for this object.
- auto network_callback_map_iter =
- network_callbacks_map_.find(network_key);
- 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::hardware::IInterface::asBinder(callback)
- ->unlinkToDeath(nullptr, callback.get()) !=
- android::OK) {
- wpa_printf(
- MSG_ERROR,
- "Error deregistering for death "
- "notification for "
- "network callback object");
- }
+ // Invoke the |onNetworkRemoved| method on all registered
+ // callbacks.
+ callWithEachStaIfaceCallback(
+ wpa_s->ifname,
+ std::bind(
+ &ISupplicantStaIfaceCallback::onNetworkRemoved,
+ std::placeholders::_1, ssid->id));
}
-#endif // TODO(b/31632518): HIDL object death notifications.
- network_callbacks_map_.erase(network_callback_map_iter);
-
- // Invoke the |onNetworkRemoved| method on all registered callbacks.
- callWithEachIfaceCallback(
- wpa_s->ifname, std::bind(
- &ISupplicantIfaceCallback::onNetworkRemoved,
- std::placeholders::_1, ssid->id));
return 0;
}
@@ -236,12 +513,12 @@
return 1;
const std::string ifname(wpa_s->ifname);
- if (iface_object_map_.find(ifname) == iface_object_map_.end())
+ if (sta_iface_object_map_.find(ifname) == sta_iface_object_map_.end())
return 1;
// Invoke the |onStateChanged| method on all registered callbacks.
- ISupplicantIfaceCallback::State hidl_state =
- static_cast<ISupplicantIfaceCallback::State>(wpa_s->wpa_state);
+ ISupplicantStaIfaceCallback::State hidl_state =
+ static_cast<ISupplicantStaIfaceCallback::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;
@@ -252,9 +529,9 @@
wpa_s->current_ssid->ssid,
wpa_s->current_ssid->ssid + wpa_s->current_ssid->ssid_len);
}
- callWithEachIfaceCallback(
+ callWithEachStaIfaceCallback(
wpa_s->ifname, std::bind(
- &ISupplicantIfaceCallback::onStateChanged,
+ &ISupplicantStaIfaceCallback::onStateChanged,
std::placeholders::_1, hidl_state, hidl_bssid,
hidl_network_id, hidl_ssid));
return 0;
@@ -278,7 +555,8 @@
const std::string network_key =
getNetworkObjectMapKey(wpa_s->ifname, ssid->id);
- if (network_object_map_.find(network_key) == network_object_map_.end())
+ if (sta_network_object_map_.find(network_key) ==
+ sta_network_object_map_.end())
return 1;
// TODO(b/31646740): Parse the param string to find the appropriate
@@ -287,7 +565,7 @@
}
/**
- * Retrieve the |ISupplicantIface| hidl object reference using the provided
+ * Retrieve the |ISupplicantP2pIface| hidl object reference using the provided
* ifname.
*
* @param ifname Name of the corresponding interface.
@@ -295,14 +573,14 @@
*
* @return 0 on success, 1 on failure.
*/
-int HidlManager::getIfaceHidlObjectByIfname(
- const std::string &ifname, android::sp<ISupplicantIface> *iface_object)
+int HidlManager::getP2pIfaceHidlObjectByIfname(
+ const std::string &ifname, android::sp<ISupplicantP2pIface> *iface_object)
{
if (ifname.empty() || !iface_object)
return 1;
- auto iface_object_iter = iface_object_map_.find(ifname);
- if (iface_object_iter == iface_object_map_.end())
+ auto iface_object_iter = p2p_iface_object_map_.find(ifname);
+ if (iface_object_iter == p2p_iface_object_map_.end())
return 1;
*iface_object = iface_object_iter->second;
@@ -310,7 +588,30 @@
}
/**
- * Retrieve the |ISupplicantNetwork| hidl object reference using the provided
+ * Retrieve the |ISupplicantStaIface| hidl object reference using the provided
+ * ifname.
+ *
+ * @param ifname Name of the corresponding interface.
+ * @param iface_object Hidl reference corresponding to the iface.
+ *
+ * @return 0 on success, 1 on failure.
+ */
+int HidlManager::getStaIfaceHidlObjectByIfname(
+ const std::string &ifname, android::sp<ISupplicantStaIface> *iface_object)
+{
+ if (ifname.empty() || !iface_object)
+ return 1;
+
+ auto iface_object_iter = sta_iface_object_map_.find(ifname);
+ if (iface_object_iter == sta_iface_object_map_.end())
+ return 1;
+
+ *iface_object = iface_object_iter->second;
+ return 0;
+}
+
+/**
+ * Retrieve the |ISupplicantP2pNetwork| hidl object reference using the provided
* ifname and network_id.
*
* @param ifname Name of the corresponding interface.
@@ -319,9 +620,9 @@
*
* @return 0 on success, 1 on failure.
*/
-int HidlManager::getNetworkHidlObjectByIfnameAndNetworkId(
+int HidlManager::getP2pNetworkHidlObjectByIfnameAndNetworkId(
const std::string &ifname, int network_id,
- android::sp<ISupplicantNetwork> *network_object)
+ android::sp<ISupplicantP2pNetwork> *network_object)
{
if (ifname.empty() || network_id < 0 || !network_object)
return 1;
@@ -330,8 +631,37 @@
const std::string network_key =
getNetworkObjectMapKey(ifname, network_id);
- auto network_object_iter = network_object_map_.find(network_key);
- if (network_object_iter == network_object_map_.end())
+ auto network_object_iter = p2p_network_object_map_.find(network_key);
+ if (network_object_iter == p2p_network_object_map_.end())
+ return 1;
+
+ *network_object = network_object_iter->second;
+ return 0;
+}
+
+/**
+ * Retrieve the |ISupplicantStaNetwork| hidl object reference using the provided
+ * ifname and network_id.
+ *
+ * @param ifname Name of the corresponding interface.
+ * @param network_id ID of the corresponding network.
+ * @param network_object Hidl reference corresponding to the network.
+ *
+ * @return 0 on success, 1 on failure.
+ */
+int HidlManager::getStaNetworkHidlObjectByIfnameAndNetworkId(
+ const std::string &ifname, int network_id,
+ android::sp<ISupplicantStaNetwork> *network_object)
+{
+ if (ifname.empty() || network_id < 0 || !network_object)
+ return 1;
+
+ // Generate the key to be used to lookup the network.
+ const std::string network_key =
+ getNetworkObjectMapKey(ifname, network_id);
+
+ auto network_object_iter = sta_network_object_map_.find(network_key);
+ if (network_object_iter == sta_network_object_map_.end())
return 1;
*network_object = network_object_iter->second;
@@ -357,83 +687,97 @@
ISupplicantCallback>(
callback, on_hidl_died_fctor, supplicant_callbacks_);
}
+
/**
- * Add a new |ISupplicantIfaceCallback| hidl object reference to our
+ * Add a new iface callback hidl object reference to our
* interface callback list.
*
* @param ifname Name of the corresponding interface.
- * @param callback Hidl reference of the |ISupplicantIfaceCallback| object.
+ * @param callback Hidl reference of the callback object.
*
* @return 0 on success, 1 on failure.
*/
-int HidlManager::addIfaceCallbackHidlObject(
+int HidlManager::addP2pIfaceCallbackHidlObject(
const std::string &ifname,
- const android::sp<ISupplicantIfaceCallback> &callback)
+ const android::sp<ISupplicantP2pIfaceCallback> &callback)
{
- if (ifname.empty())
- return 1;
-
- auto iface_callback_map_iter = iface_callbacks_map_.find(ifname);
- if (iface_callback_map_iter == iface_callbacks_map_.end())
- return 1;
- auto &iface_callback_list = iface_callback_map_iter->second;
-
- // Register for death notification before we add it to our list.
- auto on_hidl_died_fctor = std::bind(
- &HidlManager::removeIfaceCallbackHidlObject, this, ifname,
- std::placeholders::_1);
- return registerForDeathAndAddCallbackHidlObjectToList<
- ISupplicantIfaceCallback>(
- callback, on_hidl_died_fctor, iface_callback_list);
+ const std::function<void(
+ const android::sp<ISupplicantP2pIfaceCallback> &)>
+ on_hidl_died_fctor = std::bind(
+ &HidlManager::removeP2pIfaceCallbackHidlObject, this, ifname,
+ std::placeholders::_1);
+ return addIfaceCallbackHidlObjectToMap(
+ ifname, callback, on_hidl_died_fctor, p2p_iface_callbacks_map_);
}
/**
- * Add a new |ISupplicantNetworkCallback| hidl object reference to our
- * network callback list.
+ * Add a new iface callback hidl object reference to our
+ * interface callback list.
*
* @param ifname Name of the corresponding interface.
- * @param network_id ID of the corresponding network.
- * @param callback Hidl reference of the |ISupplicantNetworkCallback| object.
+ * @param callback Hidl reference of the callback object.
*
* @return 0 on success, 1 on failure.
*/
-int HidlManager::addNetworkCallbackHidlObject(
- const std::string &ifname, int network_id,
- const android::sp<ISupplicantNetworkCallback> &callback)
+int HidlManager::addStaIfaceCallbackHidlObject(
+ const std::string &ifname,
+ const android::sp<ISupplicantStaIfaceCallback> &callback)
{
- if (ifname.empty() || network_id < 0)
- return 1;
-
- // Generate the key to be used to lookup the network.
- const std::string network_key =
- getNetworkObjectMapKey(ifname, network_id);
- auto network_callback_map_iter =
- network_callbacks_map_.find(network_key);
- if (network_callback_map_iter == network_callbacks_map_.end())
- return 1;
- auto &network_callback_list = network_callback_map_iter->second;
-
- // Register for death notification before we add it to our list.
- auto on_hidl_died_fctor = std::bind(
- &HidlManager::removeNetworkCallbackHidlObject, this, ifname,
- network_id, std::placeholders::_1);
- return registerForDeathAndAddCallbackHidlObjectToList<
- ISupplicantNetworkCallback>(
- callback, on_hidl_died_fctor, network_callback_list);
+ const std::function<void(
+ const android::sp<ISupplicantStaIfaceCallback> &)>
+ on_hidl_died_fctor = std::bind(
+ &HidlManager::removeStaIfaceCallbackHidlObject, this, ifname,
+ std::placeholders::_1);
+ return addIfaceCallbackHidlObjectToMap(
+ ifname, callback, on_hidl_died_fctor, sta_iface_callbacks_map_);
}
/**
- * Creates a unique key for the network using the provided |ifname| and
- * |network_id| to be used in the internal map of |ISupplicantNetwork| objects.
- * This is of the form |ifname|_|network_id|. For ex: "wlan0_1".
+ * Add a new network callback 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 callback object.
+ *
+ * @return 0 on success, 1 on failure.
*/
-const std::string HidlManager::getNetworkObjectMapKey(
- const std::string &ifname, int network_id)
+int HidlManager::addP2pNetworkCallbackHidlObject(
+ const std::string &ifname, int network_id,
+ const android::sp<ISupplicantP2pNetworkCallback> &callback)
{
- return ifname + "_" + std::to_string(network_id);
+ const std::function<void(
+ const android::sp<ISupplicantP2pNetworkCallback> &)>
+ on_hidl_died_fctor = std::bind(
+ &HidlManager::removeP2pNetworkCallbackHidlObject, this, ifname,
+ network_id, std::placeholders::_1);
+ return addNetworkCallbackHidlObjectToMap(
+ ifname, network_id, callback, on_hidl_died_fctor,
+ p2p_network_callbacks_map_);
+}
+
+/**
+ * Add a new network callback 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 callback object.
+ *
+ * @return 0 on success, 1 on failure.
+ */
+int HidlManager::addStaNetworkCallbackHidlObject(
+ const std::string &ifname, int network_id,
+ const android::sp<ISupplicantStaNetworkCallback> &callback)
+{
+ const std::function<void(
+ const android::sp<ISupplicantStaNetworkCallback> &)>
+ on_hidl_died_fctor = std::bind(
+ &HidlManager::removeStaNetworkCallbackHidlObject, this, ifname,
+ network_id, std::placeholders::_1);
+ return addNetworkCallbackHidlObjectToMap(
+ ifname, network_id, callback, on_hidl_died_fctor,
+ sta_network_callbacks_map_);
}
/**
@@ -453,101 +797,65 @@
}
/**
- * Removes the provided |ISupplicantIfaceCallback| hidl object reference from
+ * Removes the provided iface callback hidl object reference from
* our interface callback list.
*
* @param ifname Name of the corresponding interface.
- * @param callback Hidl reference of the |ISupplicantIfaceCallback| object.
+ * @param callback Hidl reference of the callback object.
*/
-void HidlManager::removeIfaceCallbackHidlObject(
+void HidlManager::removeP2pIfaceCallbackHidlObject(
const std::string &ifname,
- const android::sp<ISupplicantIfaceCallback> &callback)
+ const android::sp<ISupplicantP2pIfaceCallback> &callback)
{
- if (ifname.empty())
- return;
-
- auto iface_callback_map_iter = iface_callbacks_map_.find(ifname);
- if (iface_callback_map_iter == iface_callbacks_map_.end())
- return;
-
- auto &iface_callback_list = iface_callback_map_iter->second;
- iface_callback_list.erase(
- std::remove(
- iface_callback_list.begin(), iface_callback_list.end(),
- callback),
- iface_callback_list.end());
+ return removeIfaceCallbackHidlObjectFromMap(
+ ifname, callback, p2p_iface_callbacks_map_);
}
/**
- * Removes the provided |ISupplicantNetworkCallback| hidl object reference from
+ * Removes the provided iface callback hidl object reference from
+ * our interface callback list.
+ *
+ * @param ifname Name of the corresponding interface.
+ * @param callback Hidl reference of the callback object.
+ */
+void HidlManager::removeStaIfaceCallbackHidlObject(
+ const std::string &ifname,
+ const android::sp<ISupplicantStaIfaceCallback> &callback)
+{
+ return removeIfaceCallbackHidlObjectFromMap(
+ ifname, callback, sta_iface_callbacks_map_);
+}
+
+/**
+ * Removes the provided network callback 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 |ISupplicantNetworkCallback| object.
+ * @param callback Hidl reference of the callback object.
*/
-void HidlManager::removeNetworkCallbackHidlObject(
+void HidlManager::removeP2pNetworkCallbackHidlObject(
const std::string &ifname, int network_id,
- const android::sp<ISupplicantNetworkCallback> &callback)
+ const android::sp<ISupplicantP2pNetworkCallback> &callback)
{
- if (ifname.empty() || network_id < 0)
- return;
-
- // Generate the key to be used to lookup the network.
- const std::string network_key =
- getNetworkObjectMapKey(ifname, network_id);
-
- auto network_callback_map_iter =
- network_callbacks_map_.find(network_key);
- if (network_callback_map_iter == network_callbacks_map_.end())
- return;
-
- auto &network_callback_list = network_callback_map_iter->second;
- network_callback_list.erase(
- std::remove(
- network_callback_list.begin(), network_callback_list.end(),
- callback),
- network_callback_list.end());
+ return removeNetworkCallbackHidlObjectFromMap(
+ ifname, network_id, callback, p2p_network_callbacks_map_);
}
/**
- * Add callback to the corresponding list after linking to death on the
- * corresponding hidl object reference.
+ * Removes the provided network callback hidl object reference from
+ * our network callback list.
*
- * @param callback Hidl reference of the |ISupplicantNetworkCallback| object.
- *
- * @return 0 on success, 1 on failure.
+ * @param ifname Name of the corresponding interface.
+ * @param network_id ID of the corresponding network.
+ * @param callback Hidl reference of the callback object.
*/
-template <class CallbackType>
-int HidlManager::registerForDeathAndAddCallbackHidlObjectToList(
- const android::sp<CallbackType> &callback,
- const std::function<void(const android::sp<CallbackType> &)>
- &on_hidl_died_fctor,
- std::vector<android::sp<CallbackType>> &callback_list)
+void HidlManager::removeStaNetworkCallbackHidlObject(
+ const std::string &ifname, int network_id,
+ const android::sp<ISupplicantStaNetworkCallback> &callback)
{
- auto death_notifier = new CallbackObjectDeathNotifier<CallbackType>(
- callback, on_hidl_died_fctor);
- // Use the |callback.get()| as cookie so that we don't need to
- // 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!
- callback_list.push_back(callback);
-#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,
- "Error registering for death notification for "
- "supplicant callback object");
- callback_list.erase(
- std::remove(
- callback_list.begin(), callback_list.end(), callback),
- callback_list.end());
- return 1;
- }
-#endif // TODO(b/31632518): HIDL object death notifications.
- return 0;
+ return removeNetworkCallbackHidlObjectFromMap(
+ ifname, network_id, callback, sta_network_callbacks_map_);
}
/**
@@ -567,62 +875,75 @@
/**
* Helper fucntion to invoke the provided callback method on all the
- * registered |ISupplicantIfaceCallback| callback hidl objects for the specified
+ * registered iface callback hidl objects for the specified
* |ifname|.
*
* @param ifname Name of the corresponding interface.
* @param method Pointer to the required hidl method from
* |ISupplicantIfaceCallback|.
*/
-void HidlManager::callWithEachIfaceCallback(
+void HidlManager::callWithEachP2pIfaceCallback(
const std::string &ifname,
- const std::function<Return<void>(android::sp<ISupplicantIfaceCallback>)>
+ const std::function<Return<void>(android::sp<ISupplicantP2pIfaceCallback>)>
&method)
{
- if (ifname.empty())
- return;
+ callWithEachIfaceCallback(ifname, method, p2p_iface_callbacks_map_);
+}
- auto iface_callback_map_iter = iface_callbacks_map_.find(ifname);
- if (iface_callback_map_iter == iface_callbacks_map_.end())
- return;
- const auto &iface_callback_list = iface_callback_map_iter->second;
- for (const auto &callback : iface_callback_list) {
- method(callback);
- }
+/**
+ * Helper fucntion to invoke the provided callback method on all the
+ * registered iface callback hidl objects for the specified
+ * |ifname|.
+ *
+ * @param ifname Name of the corresponding interface.
+ * @param method Pointer to the required hidl method from
+ * |ISupplicantIfaceCallback|.
+ */
+void HidlManager::callWithEachStaIfaceCallback(
+ const std::string &ifname,
+ const std::function<Return<void>(android::sp<ISupplicantStaIfaceCallback>)>
+ &method)
+{
+ callWithEachIfaceCallback(ifname, method, sta_iface_callbacks_map_);
}
/**
* Helper function to invoke the provided callback method on all the
- * registered |ISupplicantNetworkCallback| callback hidl objects for the
- * specified
+ * registered network 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
- * |ISupplicantNetworkCallback|.
+ * |ISupplicantP2pNetworkCallback| or |ISupplicantStaNetworkCallback| .
*/
-void HidlManager::callWithEachNetworkCallback(
+void HidlManager::callWithEachP2pNetworkCallback(
const std::string &ifname, int network_id,
- const std::function<Return<void>(android::sp<ISupplicantNetworkCallback>)>
- &method)
+ const std::function<
+ Return<void>(android::sp<ISupplicantP2pNetworkCallback>)> &method)
{
- if (ifname.empty() || network_id < 0)
- return;
-
- // Generate the key to be used to lookup the network.
- const std::string network_key =
- getNetworkObjectMapKey(ifname, network_id);
- auto network_callback_map_iter =
- network_callbacks_map_.find(network_key);
- if (network_callback_map_iter == network_callbacks_map_.end())
- return;
- const auto &network_callback_list = network_callback_map_iter->second;
- for (const auto &callback : network_callback_list) {
- method(callback);
- }
+ callWithEachNetworkCallback(
+ ifname, network_id, method, p2p_network_callbacks_map_);
}
+/**
+ * Helper function to invoke the provided callback method on all the
+ * registered network 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
+ * |ISupplicantP2pNetworkCallback| or |ISupplicantStaNetworkCallback| .
+ */
+void HidlManager::callWithEachStaNetworkCallback(
+ const std::string &ifname, int network_id,
+ const std::function<
+ Return<void>(android::sp<ISupplicantStaNetworkCallback>)> &method)
+{
+ callWithEachNetworkCallback(
+ ifname, network_id, method, sta_network_callbacks_map_);
+}
} // namespace implementation
} // namespace V1_0
} // namespace wifi
diff --git a/wpa_supplicant/hidl/hidl_manager.h b/wpa_supplicant/hidl/hidl_manager.h
index f226d2d..0678b10 100644
--- a/wpa_supplicant/hidl/hidl_manager.h
+++ b/wpa_supplicant/hidl/hidl_manager.h
@@ -14,15 +14,23 @@
#include <string>
#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 <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIfaceCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pNetworkCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetworkCallback.h>
-#include "iface.h"
-#include "network.h"
+#include "p2p_iface.h"
+#include "p2p_network.h"
+#include "sta_iface.h"
+#include "sta_network.h"
#include "supplicant.h"
-struct wpa_global;
-struct wpa_supplicant;
+extern "C" {
+#include "utils/common.h"
+#include "utils/includes.h"
+#include "wpa_supplicant_i.h"
+#include "driver_i.h"
+}
namespace android {
namespace hardware {
@@ -57,28 +65,32 @@
const char *param);
// Methods called from hidl objects.
- int getIfaceHidlObjectByIfname(
+ int getP2pIfaceHidlObjectByIfname(
const std::string &ifname,
- android::sp<
- android::hardware::wifi::supplicant::V1_0::ISupplicantIface>
- *iface_object);
- int getNetworkHidlObjectByIfnameAndNetworkId(
+ android::sp<ISupplicantP2pIface> *iface_object);
+ int getStaIfaceHidlObjectByIfname(
+ const std::string &ifname,
+ android::sp<ISupplicantStaIface> *iface_object);
+ int getP2pNetworkHidlObjectByIfnameAndNetworkId(
const std::string &ifname, int network_id,
- android::sp<
- android::hardware::wifi::supplicant::V1_0::ISupplicantNetwork>
- *network_object);
+ android::sp<ISupplicantP2pNetwork> *network_object);
+ int getStaNetworkHidlObjectByIfnameAndNetworkId(
+ const std::string &ifname, int network_id,
+ android::sp<ISupplicantStaNetwork> *network_object);
int addSupplicantCallbackHidlObject(
- const android::sp<
- android::hardware::wifi::supplicant::V1_0::ISupplicantCallback>
- &callback);
- int addIfaceCallbackHidlObject(
+ const android::sp<ISupplicantCallback> &callback);
+ int addP2pIfaceCallbackHidlObject(
const std::string &ifname,
- const android::sp<android::hardware::wifi::supplicant::V1_0::
- ISupplicantIfaceCallback> &callback);
- int addNetworkCallbackHidlObject(
+ const android::sp<ISupplicantP2pIfaceCallback> &callback);
+ int addStaIfaceCallbackHidlObject(
+ const std::string &ifname,
+ const android::sp<ISupplicantStaIfaceCallback> &callback);
+ int addP2pNetworkCallbackHidlObject(
const std::string &ifname, int network_id,
- const android::sp<android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetworkCallback> &callback);
+ const android::sp<ISupplicantP2pNetworkCallback> &callback);
+ int addStaNetworkCallbackHidlObject(
+ const std::string &ifname, int network_id,
+ const android::sp<ISupplicantStaNetworkCallback> &callback);
private:
HidlManager() = default;
@@ -86,42 +98,40 @@
HidlManager(const HidlManager &) = default;
HidlManager &operator=(const HidlManager &) = default;
- const std::string getNetworkObjectMapKey(
- const std::string &ifname, int network_id);
-
void removeSupplicantCallbackHidlObject(
- const android::sp<
- android::hardware::wifi::supplicant::V1_0::ISupplicantCallback>
- &callback);
- void removeIfaceCallbackHidlObject(
+ const android::sp<ISupplicantCallback> &callback);
+ void removeP2pIfaceCallbackHidlObject(
const std::string &ifname,
- const android::sp<android::hardware::wifi::supplicant::V1_0::
- ISupplicantIfaceCallback> &callback);
- void removeNetworkCallbackHidlObject(
+ const android::sp<ISupplicantP2pIfaceCallback> &callback);
+ void removeStaIfaceCallbackHidlObject(
+ const std::string &ifname,
+ const android::sp<ISupplicantStaIfaceCallback> &callback);
+ void removeP2pNetworkCallbackHidlObject(
const std::string &ifname, int network_id,
- const android::sp<android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetworkCallback> &callback);
- template <class CallbackType>
- int registerForDeathAndAddCallbackHidlObjectToList(
- const android::sp<CallbackType> &callback,
- const std::function<void(const android::sp<CallbackType> &)>
- &on_hidl_died_fctor,
- std::vector<android::sp<CallbackType>> &callback_list);
+ const android::sp<ISupplicantP2pNetworkCallback> &callback);
+ void removeStaNetworkCallbackHidlObject(
+ const std::string &ifname, int network_id,
+ const android::sp<ISupplicantStaNetworkCallback> &callback);
void callWithEachSupplicantCallback(
const std::function<android::hardware::Return<void>(
- android::sp<android::hardware::wifi::supplicant::V1_0::
- ISupplicantCallback>)> &method);
- void callWithEachIfaceCallback(
+ android::sp<ISupplicantCallback>)> &method);
+ void callWithEachP2pIfaceCallback(
const std::string &ifname,
const std::function<android::hardware::Return<void>(
- android::sp<android::hardware::wifi::supplicant::V1_0::
- ISupplicantIfaceCallback>)> &method);
- void callWithEachNetworkCallback(
+ android::sp<ISupplicantP2pIfaceCallback>)> &method);
+ void callWithEachStaIfaceCallback(
+ const std::string &ifname,
+ const std::function<android::hardware::Return<void>(
+ android::sp<ISupplicantStaIfaceCallback>)> &method);
+ void callWithEachP2pNetworkCallback(
const std::string &ifname, int network_id,
const std::function<android::hardware::Return<void>(
- android::sp<android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetworkCallback>)> &method);
+ android::sp<ISupplicantP2pNetworkCallback>)> &method);
+ void callWithEachStaNetworkCallback(
+ const std::string &ifname, int network_id,
+ const std::function<android::hardware::Return<void>(
+ android::sp<ISupplicantStaNetworkCallback>)> &method);
// HIDL Service name.
static const char kServiceName[];
@@ -129,35 +139,57 @@
static HidlManager *instance_;
// The main hidl service object.
android::sp<Supplicant> supplicant_object_;
- // Map of all the interface specific hidl objects controlled by
+ // Map of all the P2P interface specific hidl objects controlled by
// wpa_supplicant. This map is keyed in by the corresponding
// |ifname|.
- std::map<const std::string, android::sp<Iface>> iface_object_map_;
- // Map of all the network specific hidl objects controlled by
+ std::map<const std::string, android::sp<P2pIface>>
+ p2p_iface_object_map_;
+ // Map of all the STA interface specific hidl objects controlled by
+ // wpa_supplicant. This map is keyed in by the corresponding
+ // |ifname|.
+ std::map<const std::string, android::sp<StaIface>>
+ sta_iface_object_map_;
+ // Map of all the P2P network specific hidl objects controlled by
// wpa_supplicant. This map is keyed in by the corresponding
// |ifname| & |network_id|.
- std::map<const std::string, android::sp<Network>> network_object_map_;
+ std::map<const std::string, android::sp<P2pNetwork>>
+ p2p_network_object_map_;
+ // Map of all the STA network specific hidl objects controlled by
+ // wpa_supplicant. This map is keyed in by the corresponding
+ // |ifname| & |network_id|.
+ std::map<const std::string, android::sp<StaNetwork>>
+ sta_network_object_map_;
// Callback registered for the main hidl service object.
- std::vector<android::sp<
- android::hardware::wifi::supplicant::V1_0::ISupplicantCallback>>
- supplicant_callbacks_;
- // Map of all the callbacks registered for interface specific
+ std::vector<android::sp<ISupplicantCallback>> supplicant_callbacks_;
+ // Map of all the callbacks registered for P2P 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<android::hardware::wifi::supplicant::V1_0::
- ISupplicantIfaceCallback>>>
- iface_callbacks_map_;
- // Map of all the callbacks registered for network specific
+ std::vector<android::sp<ISupplicantP2pIfaceCallback>>>
+ p2p_iface_callbacks_map_;
+ // Map of all the callbacks registered for STA 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<ISupplicantStaIfaceCallback>>>
+ sta_iface_callbacks_map_;
+ // Map of all the callbacks registered for P2P 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<android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetworkCallback>>>
- network_callbacks_map_;
+ std::vector<android::sp<ISupplicantP2pNetworkCallback>>>
+ p2p_network_callbacks_map_;
+ // Map of all the callbacks registered for STA 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<ISupplicantStaNetworkCallback>>>
+ sta_network_callbacks_map_;
/**
* Helper class used to deregister the callback object reference from
@@ -196,109 +228,87 @@
// avoid nasty runtime conversion functions. So, adding compile time asserts
// to guard against any internal changes breaking the hidl interface.
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicant::DebugLevel::EXCESSIVE) ==
- MSG_EXCESSIVE,
+ static_cast<uint32_t>(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,
+ static_cast<uint32_t>(ISupplicant::DebugLevel::ERROR) == MSG_ERROR,
"Debug level value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::KeyMgmtMask::NONE) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::KeyMgmtMask::NONE) ==
WPA_KEY_MGMT_NONE,
"KeyMgmt value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::KeyMgmtMask::WPA_PSK) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::KeyMgmtMask::WPA_PSK) ==
WPA_KEY_MGMT_PSK,
"KeyMgmt value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::KeyMgmtMask::WPA_EAP) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::KeyMgmtMask::WPA_EAP) ==
WPA_KEY_MGMT_IEEE8021X,
"KeyMgmt value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::KeyMgmtMask::IEEE8021X) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::KeyMgmtMask::IEEE8021X) ==
WPA_KEY_MGMT_IEEE8021X_NO_WPA,
"KeyMgmt value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::ProtoMask::WPA) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::ProtoMask::WPA) ==
WPA_PROTO_WPA,
"Proto value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::ProtoMask::RSN) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::ProtoMask::RSN) ==
WPA_PROTO_RSN,
"Proto value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::ProtoMask::OSEN) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::ProtoMask::OSEN) ==
WPA_PROTO_OSEN,
"Proto value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::AuthAlgMask::OPEN) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::AuthAlgMask::OPEN) ==
WPA_AUTH_ALG_OPEN,
"AuthAlg value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::AuthAlgMask::SHARED) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::AuthAlgMask::SHARED) ==
WPA_AUTH_ALG_SHARED,
"AuthAlg value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::AuthAlgMask::LEAP) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::AuthAlgMask::LEAP) ==
WPA_AUTH_ALG_LEAP,
"AuthAlg value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::GroupCipherMask::WEP40) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::GroupCipherMask::WEP40) ==
WPA_CIPHER_WEP40,
"GroupCipher value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::GroupCipherMask::WEP104) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::GroupCipherMask::WEP104) ==
WPA_CIPHER_WEP104,
"GroupCipher value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::GroupCipherMask::TKIP) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::GroupCipherMask::TKIP) ==
WPA_CIPHER_TKIP,
"GroupCipher value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::GroupCipherMask::CCMP) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::GroupCipherMask::CCMP) ==
WPA_CIPHER_CCMP,
"GroupCipher value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::PairwiseCipherMask::NONE) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::PairwiseCipherMask::NONE) ==
WPA_CIPHER_NONE,
"PairwiseCipher value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::PairwiseCipherMask::TKIP) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::PairwiseCipherMask::TKIP) ==
WPA_CIPHER_TKIP,
"PairwiseCipher value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantNetwork::PairwiseCipherMask::CCMP) ==
+ static_cast<uint32_t>(ISupplicantStaNetwork::PairwiseCipherMask::CCMP) ==
WPA_CIPHER_CCMP,
"PairwiseCipher value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantIfaceCallback::State::DISCONNECTED) ==
+ static_cast<uint32_t>(ISupplicantStaIfaceCallback::State::DISCONNECTED) ==
WPA_DISCONNECTED,
"State value mismatch");
static_assert(
- static_cast<uint32_t>(android::hardware::wifi::supplicant::V1_0::
- ISupplicantIfaceCallback::State::COMPLETED) ==
+ static_cast<uint32_t>(ISupplicantStaIfaceCallback::State::COMPLETED) ==
WPA_COMPLETED,
"State value mismatch");
diff --git a/wpa_supplicant/hidl/p2p_iface.cpp b/wpa_supplicant/hidl/p2p_iface.cpp
new file mode 100644
index 0000000..e9ee986
--- /dev/null
+++ b/wpa_supplicant/hidl/p2p_iface.cpp
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+#include "hidl_manager.h"
+#include "hidl_return_macros.h"
+#include "p2p_iface.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
+
+P2pIface::P2pIface(struct wpa_global *wpa_global, const char ifname[])
+ : wpa_global_(wpa_global), ifname_(ifname)
+{
+}
+
+Return<void> P2pIface::getName(getName_cb _hidl_cb)
+{
+ struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID, ifname_);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
+}
+
+Return<void> P2pIface::getType(getType_cb _hidl_cb)
+{
+ struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID,
+ IfaceType::STA);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, IfaceType::STA);
+}
+
+Return<void> P2pIface::addNetwork(addNetwork_cb _hidl_cb)
+{
+ android::sp<ISupplicantP2pNetwork> network;
+ struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID, network);
+ }
+
+ struct wpa_ssid *ssid = wpa_supplicant_add_network(wpa_s);
+ if (!ssid) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
+ }
+
+ HidlManager *hidl_manager = HidlManager::getInstance();
+ if (!hidl_manager ||
+ hidl_manager->getP2pNetworkHidlObjectByIfnameAndNetworkId(
+ wpa_s->ifname, ssid->id, &network)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
+}
+
+Return<void> P2pIface::removeNetwork(uint32_t id, removeNetwork_cb _hidl_cb)
+{
+ struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+ }
+
+ int result = wpa_supplicant_remove_network(wpa_s, id);
+ if (result == -1) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN);
+ }
+
+ if (result != 0) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+}
+
+Return<void> P2pIface::getNetwork(uint32_t id, getNetwork_cb _hidl_cb)
+{
+ android::sp<ISupplicantP2pNetwork> network;
+ struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID, network);
+ }
+
+ struct wpa_ssid *ssid = wpa_config_get_network(wpa_s->conf, id);
+ if (!ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN, network);
+ }
+
+ HidlManager *hidl_manager = HidlManager::getInstance();
+ if (!hidl_manager ||
+ hidl_manager->getP2pNetworkHidlObjectByIfnameAndNetworkId(
+ wpa_s->ifname, ssid->id, &network)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
+}
+
+Return<void> P2pIface::listNetworks(listNetworks_cb _hidl_cb)
+{
+ std::vector<uint32_t> network_ids;
+
+ struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
+ 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> P2pIface::registerCallback(
+ const sp<ISupplicantP2pIfaceCallback> &callback,
+ registerCallback_cb _hidl_cb)
+{
+ struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+ }
+
+ HidlManager *hidl_manager = HidlManager::getInstance();
+ if (!hidl_manager ||
+ hidl_manager->addP2pIfaceCallbackHidlObject(ifname_, callback)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ 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.
+ */
+wpa_supplicant *P2pIface::retrieveP2pIfacePtr()
+{
+ return wpa_supplicant_get_iface(
+ (struct wpa_global *)wpa_global_, ifname_.c_str());
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
diff --git a/wpa_supplicant/hidl/p2p_iface.h b/wpa_supplicant/hidl/p2p_iface.h
new file mode 100644
index 0000000..a003cf5
--- /dev/null
+++ b/wpa_supplicant/hidl/p2p_iface.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+#ifndef WPA_SUPPLICANT_HIDL_P2P_IFACE_H
+#define WPA_SUPPLICANT_HIDL_P2P_IFACE_H
+
+#include <android-base/macros.h>
+
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIface.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIfaceCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pNetwork.h>
+
+extern "C" {
+#include "utils/common.h"
+#include "utils/includes.h"
+#include "wpa_supplicant_i.h"
+#include "config.h"
+#include "driver_i.h"
+}
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * Implementation of P2pIface hidl object. Each unique hidl
+ * object is used for control operations on a specific interface
+ * controlled by wpa_supplicant.
+ */
+class P2pIface
+ : public android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface
+{
+public:
+ P2pIface(struct wpa_global* wpa_global, const char ifname[]);
+ ~P2pIface() override = default;
+
+ // Hidl methods exposed.
+ Return<void> getName(getName_cb _hidl_cb) override;
+ Return<void> getType(getType_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<ISupplicantP2pIfaceCallback>& callback,
+ registerCallback_cb _hidl_cb) override;
+
+private:
+ struct wpa_supplicant* retrieveP2pIfacePtr();
+
+ // 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 hidl object controls
+ const std::string ifname_;
+
+ DISALLOW_COPY_AND_ASSIGN(P2pIface);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
+
+#endif // WPA_SUPPLICANT_HIDL_P2P_IFACE_H
diff --git a/wpa_supplicant/hidl/p2p_network.cpp b/wpa_supplicant/hidl/p2p_network.cpp
new file mode 100644
index 0000000..7de950e
--- /dev/null
+++ b/wpa_supplicant/hidl/p2p_network.cpp
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+#include "hidl_manager.h"
+#include "hidl_return_macros.h"
+#include "p2p_network.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
+
+P2pNetwork::P2pNetwork(
+ struct wpa_global *wpa_global, const char ifname[], int network_id)
+ : wpa_global_(wpa_global), ifname_(ifname), network_id_(network_id)
+{
+}
+
+Return<void> P2pNetwork::getId(getId_cb _hidl_cb)
+{
+ 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);
+}
+
+Return<void> P2pNetwork::getInterfaceName(getInterfaceName_cb _hidl_cb)
+{
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_NETWORK_INVALID, ifname_);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
+}
+
+Return<void> P2pNetwork::getType(getType_cb _hidl_cb)
+{
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID,
+ IfaceType::P2P);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, IfaceType::P2P);
+}
+
+Return<void> P2pNetwork::registerCallback(
+ const sp<ISupplicantP2pNetworkCallback> &callback,
+ registerCallback_cb _hidl_cb)
+{
+ 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->addP2pNetworkCallbackHidlObject(
+ ifname_, network_id_, callback)) {
+ HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ 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.
+ */
+struct wpa_ssid *P2pNetwork::retrieveNetworkPtr()
+{
+ wpa_supplicant *wpa_s = retrieveIfacePtr();
+ if (!wpa_s)
+ return nullptr;
+ return wpa_config_get_network(wpa_s->conf, network_id_);
+}
+
+/**
+ * Retrieve the underlying |wpa_supplicant| struct
+ * pointer for this network.
+ */
+struct wpa_supplicant *P2pNetwork::retrieveIfacePtr()
+{
+ return wpa_supplicant_get_iface(
+ (struct wpa_global *)wpa_global_, ifname_.c_str());
+}
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
diff --git a/wpa_supplicant/hidl/p2p_network.h b/wpa_supplicant/hidl/p2p_network.h
new file mode 100644
index 0000000..92eddd2
--- /dev/null
+++ b/wpa_supplicant/hidl/p2p_network.h
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+#ifndef WPA_SUPPLICANT_HIDL_P2P_NETWORK_H
+#define WPA_SUPPLICANT_HIDL_P2P_NETWORK_H
+
+#include <android-base/macros.h>
+
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pNetwork.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pNetworkCallback.h>
+
+extern "C" {
+#include "utils/common.h"
+#include "utils/includes.h"
+#include "config.h"
+#include "wpa_supplicant_i.h"
+#include "notify.h"
+#include "eapol_supp/eapol_supp_sm.h"
+#include "eap_peer/eap.h"
+#include "rsn_supp/wpa.h"
+}
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * Implementation of P2pNetwork hidl object. Each unique hidl
+ * object is used for control operations on a specific network
+ * controlled by wpa_supplicant.
+ */
+class P2pNetwork : public ISupplicantP2pNetwork
+{
+public:
+ P2pNetwork(
+ struct wpa_global* wpa_global, const char ifname[], int network_id);
+ ~P2pNetwork() override = default;
+
+ // Hidl methods exposed.
+ Return<void> getId(getId_cb _hidl_cb) override;
+ Return<void> getInterfaceName(getInterfaceName_cb _hidl_cb) override;
+ Return<void> getType(getType_cb _hidl_cb) override;
+ Return<void> registerCallback(
+ const sp<ISupplicantP2pNetworkCallback>& callback,
+ registerCallback_cb _hidl_cb) override;
+
+private:
+ struct wpa_ssid* retrieveNetworkPtr();
+ 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_;
+ // Name of the iface this network belongs to.
+ const std::string ifname_;
+ // Id of the network this hidl object controls.
+ const int network_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(P2pNetwork);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace supplicant
+} // namespace hardware
+} // namespace android
+
+#endif // WPA_SUPPLICANT_HIDL_P2P_NETWORK_H
diff --git a/wpa_supplicant/hidl/iface.cpp b/wpa_supplicant/hidl/sta_iface.cpp
similarity index 81%
rename from wpa_supplicant/hidl/iface.cpp
rename to wpa_supplicant/hidl/sta_iface.cpp
index 6b94aa1..e3a384b 100644
--- a/wpa_supplicant/hidl/iface.cpp
+++ b/wpa_supplicant/hidl/sta_iface.cpp
@@ -9,7 +9,7 @@
#include "hidl_manager.h"
#include "hidl_return_macros.h"
-#include "iface.h"
+#include "sta_iface.h"
namespace android {
namespace hardware {
@@ -18,12 +18,12 @@
namespace V1_0 {
namespace implementation {
-Iface::Iface(struct wpa_global *wpa_global, const char ifname[])
+StaIface::StaIface(struct wpa_global *wpa_global, const char ifname[])
: wpa_global_(wpa_global), ifname_(ifname)
{
}
-Return<void> Iface::getName(getName_cb _hidl_cb)
+Return<void> StaIface::getName(getName_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
@@ -34,9 +34,21 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
}
-Return<void> Iface::addNetwork(addNetwork_cb _hidl_cb)
+Return<void> StaIface::getType(getType_cb _hidl_cb)
{
- android::sp<ISupplicantNetwork> network;
+ struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+ if (!wpa_s) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID,
+ IfaceType::STA);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, IfaceType::STA);
+}
+
+Return<void> StaIface::addNetwork(addNetwork_cb _hidl_cb)
+{
+ android::sp<ISupplicantStaNetwork> network;
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
HIDL_RETURN(
@@ -50,7 +62,7 @@
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
- hidl_manager->getNetworkHidlObjectByIfnameAndNetworkId(
+ hidl_manager->getStaNetworkHidlObjectByIfnameAndNetworkId(
wpa_s->ifname, ssid->id, &network)) {
HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
}
@@ -58,7 +70,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
}
-Return<void> Iface::removeNetwork(uint32_t id, removeNetwork_cb _hidl_cb)
+Return<void> StaIface::removeNetwork(uint32_t id, removeNetwork_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
@@ -77,9 +89,9 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Iface::getNetwork(uint32_t id, getNetwork_cb _hidl_cb)
+Return<void> StaIface::getNetwork(uint32_t id, getNetwork_cb _hidl_cb)
{
- android::sp<ISupplicantNetwork> network;
+ android::sp<ISupplicantStaNetwork> network;
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
HIDL_RETURN(
@@ -94,7 +106,7 @@
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
- hidl_manager->getNetworkHidlObjectByIfnameAndNetworkId(
+ hidl_manager->getStaNetworkHidlObjectByIfnameAndNetworkId(
wpa_s->ifname, ssid->id, &network)) {
HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
}
@@ -102,7 +114,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
}
-Return<void> Iface::listNetworks(listNetworks_cb _hidl_cb)
+Return<void> StaIface::listNetworks(listNetworks_cb _hidl_cb)
{
std::vector<uint32_t> network_ids;
@@ -120,8 +132,9 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, network_ids);
}
-Return<void> Iface::registerCallback(
- const sp<ISupplicantIfaceCallback> &callback, registerCallback_cb _hidl_cb)
+Return<void> StaIface::registerCallback(
+ const sp<ISupplicantStaIfaceCallback> &callback,
+ registerCallback_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
@@ -130,14 +143,14 @@
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
- hidl_manager->addIfaceCallbackHidlObject(ifname_, callback)) {
+ hidl_manager->addStaIfaceCallbackHidlObject(ifname_, callback)) {
HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Iface::reassociate(reassociate_cb _hidl_cb)
+Return<void> StaIface::reassociate(reassociate_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
@@ -151,7 +164,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Iface::reconnect(reconnect_cb _hidl_cb)
+Return<void> StaIface::reconnect(reconnect_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
@@ -171,7 +184,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Iface::disconnect(disconnect_cb _hidl_cb)
+Return<void> StaIface::disconnect(disconnect_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
@@ -187,7 +200,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Iface::setPowerSave(bool enable, setPowerSave_cb _hidl_cb)
+Return<void> StaIface::setPowerSave(bool enable, setPowerSave_cb _hidl_cb)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s) {
@@ -201,7 +214,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Iface::initiateTdlsDiscover(
+Return<void> StaIface::initiateTdlsDiscover(
const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
initiateTdlsDiscover_cb _hidl_cb)
{
@@ -228,7 +241,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Iface::initiateTdlsSetup(
+Return<void> StaIface::initiateTdlsSetup(
const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
initiateTdlsSetup_cb _hidl_cb)
{
@@ -257,7 +270,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Iface::initiateTdlsTeardown(
+Return<void> StaIface::initiateTdlsTeardown(
const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
initiateTdlsTeardown_cb _hidl_cb)
{
@@ -293,7 +306,7 @@
* If the underlying iface is removed, then all RPC method calls on this object
* will return failure.
*/
-wpa_supplicant *Iface::retrieveIfacePtr()
+wpa_supplicant *StaIface::retrieveIfacePtr()
{
return wpa_supplicant_get_iface(
(struct wpa_global *)wpa_global_, ifname_.c_str());
diff --git a/wpa_supplicant/hidl/iface.h b/wpa_supplicant/hidl/sta_iface.h
similarity index 74%
rename from wpa_supplicant/hidl/iface.h
rename to wpa_supplicant/hidl/sta_iface.h
index 3be2675..f246bbc 100644
--- a/wpa_supplicant/hidl/iface.h
+++ b/wpa_supplicant/hidl/sta_iface.h
@@ -7,20 +7,22 @@
* See README for more details.
*/
-#ifndef WPA_SUPPLICANT_HIDL_IFACE_H
-#define WPA_SUPPLICANT_HIDL_IFACE_H
+#ifndef WPA_SUPPLICANT_HIDL_STA_IFACE_H
+#define WPA_SUPPLICANT_HIDL_STA_IFACE_H
#include <android-base/macros.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>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
extern "C" {
#include "utils/common.h"
#include "utils/includes.h"
#include "wpa_supplicant_i.h"
+#include "config.h"
#include "driver_i.h"
+#include "wpa.h"
}
namespace android {
@@ -31,25 +33,27 @@
namespace implementation {
/**
- * Implementation of Iface hidl object. Each unique hidl
+ * Implementation of StaIface hidl object. Each unique hidl
* object is used for control operations on a specific interface
* controlled by wpa_supplicant.
*/
-class Iface : public android::hardware::wifi::supplicant::V1_0::ISupplicantIface
+class StaIface
+ : public android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface
{
public:
- Iface(struct wpa_global* wpa_global, const char ifname[]);
- ~Iface() override = default;
+ StaIface(struct wpa_global* wpa_global, const char ifname[]);
+ ~StaIface() override = default;
// Hidl methods exposed.
Return<void> getName(getName_cb _hidl_cb) override;
+ Return<void> getType(getType_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,
+ const sp<ISupplicantStaIfaceCallback>& callback,
registerCallback_cb _hidl_cb) override;
Return<void> reassociate(reassociate_cb _hidl_cb) override;
Return<void> reconnect(reconnect_cb _hidl_cb) override;
@@ -75,7 +79,7 @@
// Name of the iface this hidl object controls
const std::string ifname_;
- DISALLOW_COPY_AND_ASSIGN(Iface);
+ DISALLOW_COPY_AND_ASSIGN(StaIface);
};
} // namespace implementation
@@ -85,4 +89,4 @@
} // namespace hardware
} // namespace android
-#endif // WPA_SUPPLICANT_HIDL_IFACE_H
+#endif // WPA_SUPPLICANT_HIDL_STA_IFACE_H
diff --git a/wpa_supplicant/hidl/network.cpp b/wpa_supplicant/hidl/sta_network.cpp
similarity index 84%
rename from wpa_supplicant/hidl/network.cpp
rename to wpa_supplicant/hidl/sta_network.cpp
index a7824fe..c782101 100644
--- a/wpa_supplicant/hidl/network.cpp
+++ b/wpa_supplicant/hidl/sta_network.cpp
@@ -9,43 +9,43 @@
#include "hidl_manager.h"
#include "hidl_return_macros.h"
-#include "network.h"
+#include "sta_network.h"
namespace {
-using android::hardware::wifi::supplicant::V1_0::ISupplicantNetwork;
+using android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
using android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
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));
+ (static_cast<uint32_t>(ISupplicantStaNetwork::KeyMgmtMask::NONE) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::KeyMgmtMask::WPA_PSK) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::KeyMgmtMask::WPA_EAP) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::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));
+ (static_cast<uint32_t>(ISupplicantStaNetwork::ProtoMask::WPA) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::ProtoMask::RSN) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::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));
+ (static_cast<uint32_t>(ISupplicantStaNetwork::AuthAlgMask::OPEN) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::AuthAlgMask::SHARED) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::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));
+ (static_cast<uint32_t>(ISupplicantStaNetwork::GroupCipherMask::WEP40) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::GroupCipherMask::WEP104) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::GroupCipherMask::TKIP) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::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));
+ (static_cast<uint32_t>(ISupplicantStaNetwork::PairwiseCipherMask::NONE) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::PairwiseCipherMask::TKIP) |
+ static_cast<uint32_t>(ISupplicantStaNetwork::PairwiseCipherMask::CCMP));
constexpr uint32_t kEapMethodMax =
- static_cast<uint32_t>(ISupplicantNetwork::EapMethod::WFA_UNAUTH_TLS) + 1;
+ static_cast<uint32_t>(ISupplicantStaNetwork::EapMethod::WFA_UNAUTH_TLS) + 1;
constexpr char const *kEapMethodStrings[kEapMethodMax] = {
"PEAP", "TLS", "TTLS", "PWD", "SIM", "AKA", "AKA'", "WFA-UNAUTH-TLS"};
constexpr uint32_t kEapPhase2MethodMax =
- static_cast<uint32_t>(ISupplicantNetwork::EapPhase2Method::GTC) + 1;
+ static_cast<uint32_t>(ISupplicantStaNetwork::EapPhase2Method::GTC) + 1;
constexpr char const *kEapPhase2MethodStrings[kEapPhase2MethodMax] = {
"NULL", "PAP", "MSCHAP", "MSCHAPV2", "GTC"};
} // namespace
@@ -57,13 +57,13 @@
namespace V1_0 {
namespace implementation {
-Network::Network(
+StaNetwork::StaNetwork(
struct wpa_global *wpa_global, const char ifname[], int network_id)
: wpa_global_(wpa_global), ifname_(ifname), network_id_(network_id)
{
}
-Return<void> Network::getId(getId_cb _hidl_cb)
+Return<void> StaNetwork::getId(getId_cb _hidl_cb)
{
uint32_t id = UINT32_MAX;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -75,7 +75,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, id);
}
-Return<void> Network::getInterfaceName(getInterfaceName_cb _hidl_cb)
+Return<void> StaNetwork::getInterfaceName(getInterfaceName_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -86,8 +86,20 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
}
-Return<void> Network::registerCallback(
- const sp<ISupplicantNetworkCallback> &callback,
+Return<void> StaNetwork::getType(getType_cb _hidl_cb)
+{
+ struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
+ if (!wpa_ssid) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_INVALID,
+ IfaceType::STA);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, IfaceType::STA);
+}
+
+Return<void> StaNetwork::registerCallback(
+ const sp<ISupplicantStaNetworkCallback> &callback,
registerCallback_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -97,7 +109,7 @@
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager ||
- hidl_manager->addNetworkCallbackHidlObject(
+ hidl_manager->addStaNetworkCallbackHidlObject(
ifname_, network_id_, callback)) {
HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
}
@@ -105,7 +117,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setSsid(
+Return<void> StaNetwork::setSsid(
const hidl_vec<uint8_t> &ssid, setSsid_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -115,7 +127,7 @@
if (ssid.size() == 0 ||
ssid.size() >
- static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
SSID_MAX_LEN_IN_BYTES)) {
HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
@@ -132,7 +144,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setBssid(
+Return<void> StaNetwork::setBssid(
const hidl_array<uint8_t, 6 /* 6 */> &bssid, setBssid_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -165,7 +177,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setScanSsid(bool enable, setScanSsid_cb _hidl_cb)
+Return<void> StaNetwork::setScanSsid(bool enable, setScanSsid_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -178,7 +190,8 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setKeyMgmt(uint32_t key_mgmt_mask, setKeyMgmt_cb _hidl_cb)
+Return<void> StaNetwork::setKeyMgmt(
+ uint32_t key_mgmt_mask, setKeyMgmt_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -195,7 +208,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setProto(uint32_t proto_mask, setProto_cb _hidl_cb)
+Return<void> StaNetwork::setProto(uint32_t proto_mask, setProto_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -212,7 +225,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setAuthAlg(
+Return<void> StaNetwork::setAuthAlg(
uint32_t auth_alg_mask,
std::function<void(const SupplicantStatus &status)> _hidl_cb)
{
@@ -231,7 +244,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setGroupCipher(
+Return<void> StaNetwork::setGroupCipher(
uint32_t group_cipher_mask, setGroupCipher_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -249,7 +262,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setPairwiseCipher(
+Return<void> StaNetwork::setPairwiseCipher(
uint32_t pairwise_cipher_mask, setPairwiseCipher_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -268,7 +281,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setPskPassphrase(
+Return<void> StaNetwork::setPskPassphrase(
const hidl_string &psk, setPskPassphrase_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -298,7 +311,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setWepKey(
+Return<void> StaNetwork::setWepKey(
uint32_t key_idx, const hidl_vec<uint8_t> &wep_key, setWepKey_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -308,14 +321,14 @@
if (key_idx >=
static_cast<uint32_t>(
- ISupplicantNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
+ ISupplicantStaNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
if (wep_key.size() !=
- static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
WEP40_KEY_LEN_IN_BYTES) &&
wep_key.size() !=
- static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
WEP104_KEY_LEN_IN_BYTES)) {
HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
@@ -330,7 +343,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setWepTxKeyIdx(
+Return<void> StaNetwork::setWepTxKeyIdx(
uint32_t key_idx, setWepTxKeyIdx_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -340,7 +353,7 @@
if (key_idx >=
static_cast<uint32_t>(
- ISupplicantNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
+ ISupplicantStaNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
}
wpa_ssid->wep_tx_keyidx = key_idx;
@@ -349,7 +362,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setRequirePmf(bool enable, setRequirePmf_cb _hidl_cb)
+Return<void> StaNetwork::setRequirePmf(bool enable, setRequirePmf_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -363,8 +376,8 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapMethod(
- ISupplicantNetwork::EapMethod method, setEapMethod_cb _hidl_cb)
+Return<void> StaNetwork::setEapMethod(
+ ISupplicantStaNetwork::EapMethod method, setEapMethod_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -417,8 +430,9 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapPhase2Method(
- ISupplicantNetwork::EapPhase2Method method, setEapPhase2Method_cb _hidl_cb)
+Return<void> StaNetwork::setEapPhase2Method(
+ ISupplicantStaNetwork::EapPhase2Method method,
+ setEapPhase2Method_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -434,7 +448,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapIdentity(
+Return<void> StaNetwork::setEapIdentity(
const hidl_vec<uint8_t> &identity, setEapIdentity_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -451,7 +465,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapAnonymousIdentity(
+Return<void> StaNetwork::setEapAnonymousIdentity(
const hidl_vec<uint8_t> &identity, setEapAnonymousIdentity_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -470,7 +484,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapPassword(
+Return<void> StaNetwork::setEapPassword(
const hidl_vec<uint8_t> &password, setEapPassword_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -489,7 +503,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapCACert(
+Return<void> StaNetwork::setEapCACert(
const hidl_string &path, setEapCACert_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -505,7 +519,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapCAPath(
+Return<void> StaNetwork::setEapCAPath(
const hidl_string &path, setEapCAPath_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -521,7 +535,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapClientCert(
+Return<void> StaNetwork::setEapClientCert(
const hidl_string &path, setEapClientCert_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -538,7 +552,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapPrivateKey(
+Return<void> StaNetwork::setEapPrivateKey(
const hidl_string &path, setEapPrivateKey_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -555,7 +569,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapSubjectMatch(
+Return<void> StaNetwork::setEapSubjectMatch(
const hidl_string &match, setEapSubjectMatch_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -572,7 +586,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapAltSubjectMatch(
+Return<void> StaNetwork::setEapAltSubjectMatch(
const hidl_string &match, setEapAltSubjectMatch_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -589,7 +603,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapEngine(bool enable, setEapEngine_cb _hidl_cb)
+Return<void> StaNetwork::setEapEngine(bool enable, setEapEngine_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -601,7 +615,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapEngineID(
+Return<void> StaNetwork::setEapEngineID(
const hidl_string &id, setEapEngineID_cb _hidl_cb)
{
@@ -618,7 +632,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::setEapDomainSuffixMatch(
+Return<void> StaNetwork::setEapDomainSuffixMatch(
const hidl_string &match, setEapDomainSuffixMatch_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -635,7 +649,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::getSsid(getSsid_cb _hidl_cb)
+Return<void> StaNetwork::getSsid(getSsid_cb _hidl_cb)
{
std::vector<uint8_t> ssid;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -649,7 +663,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, ssid);
}
-Return<void> Network::getBssid(getBssid_cb _hidl_cb)
+Return<void> StaNetwork::getBssid(getBssid_cb _hidl_cb)
{
hidl_array<uint8_t, 6> bssid;
os_memcpy(bssid.data(), kZeroBssid, ETH_ALEN);
@@ -666,7 +680,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, bssid);
}
-Return<void> Network::getScanSsid(getScanSsid_cb _hidl_cb)
+Return<void> StaNetwork::getScanSsid(getScanSsid_cb _hidl_cb)
{
bool enabled = false;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -680,7 +694,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, enabled);
}
-Return<void> Network::getKeyMgmt(getKeyMgmt_cb _hidl_cb)
+Return<void> StaNetwork::getKeyMgmt(getKeyMgmt_cb _hidl_cb)
{
uint32_t key_mgmt_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -695,7 +709,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, key_mgmt_mask);
}
-Return<void> Network::getProto(getProto_cb _hidl_cb)
+Return<void> StaNetwork::getProto(getProto_cb _hidl_cb)
{
uint32_t proto_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -709,7 +723,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, proto_mask);
}
-Return<void> Network::getAuthAlg(getAuthAlg_cb _hidl_cb)
+Return<void> StaNetwork::getAuthAlg(getAuthAlg_cb _hidl_cb)
{
uint32_t auth_alg_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -724,7 +738,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, auth_alg_mask);
}
-Return<void> Network::getGroupCipher(getGroupCipher_cb _hidl_cb)
+Return<void> StaNetwork::getGroupCipher(getGroupCipher_cb _hidl_cb)
{
uint32_t group_cipher_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -739,7 +753,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, group_cipher_mask);
}
-Return<void> Network::getPairwiseCipher(getPairwiseCipher_cb _hidl_cb)
+Return<void> StaNetwork::getPairwiseCipher(getPairwiseCipher_cb _hidl_cb)
{
uint32_t pairwise_cipher_mask = 0;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -754,7 +768,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, pairwise_cipher_mask);
}
-Return<void> Network::getPskPassphrase(getPskPassphrase_cb _hidl_cb)
+Return<void> StaNetwork::getPskPassphrase(getPskPassphrase_cb _hidl_cb)
{
hidl_string psk;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -769,7 +783,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, psk);
}
-Return<void> Network::getWepKey(uint32_t key_idx, getWepKey_cb _hidl_cb)
+Return<void> StaNetwork::getWepKey(uint32_t key_idx, getWepKey_cb _hidl_cb)
{
std::vector<uint8_t> wep_key;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -781,7 +795,7 @@
if (key_idx >=
static_cast<uint32_t>(
- ISupplicantNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
+ ISupplicantStaNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
HIDL_RETURN(
SupplicantStatusCode::FAILURE_ARGS_INVALID, wep_key);
}
@@ -793,7 +807,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, wep_key);
}
-Return<void> Network::getWepTxKeyIdx(getWepTxKeyIdx_cb _hidl_cb)
+Return<void> StaNetwork::getWepTxKeyIdx(getWepTxKeyIdx_cb _hidl_cb)
{
uint32_t wep_tx_key_idx = UINT32_MAX;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -808,7 +822,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, wep_tx_key_idx);
}
-Return<void> Network::getRequirePmf(getRequirePmf_cb _hidl_cb)
+Return<void> StaNetwork::getRequirePmf(getRequirePmf_cb _hidl_cb)
{
bool enabled = false;
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -822,7 +836,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS, enabled);
}
-Return<void> Network::enable(bool no_connect, enable_cb _hidl_cb)
+Return<void> StaNetwork::enable(bool no_connect, enable_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -845,7 +859,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::disable(disable_cb _hidl_cb)
+Return<void> StaNetwork::disable(disable_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -862,7 +876,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::select(select_cb _hidl_cb)
+Return<void> StaNetwork::select(select_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (!wpa_ssid) {
@@ -881,8 +895,8 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::sendNetworkEapSimGsmAuthResponse(
- const ISupplicantNetwork::NetworkResponseEapSimGsmAuthParams ¶ms,
+Return<void> StaNetwork::sendNetworkEapSimGsmAuthResponse(
+ const ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams ¶ms,
sendNetworkEapSimGsmAuthResponse_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -923,8 +937,8 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::sendNetworkEapSimUmtsAuthResponse(
- const ISupplicantNetwork::NetworkResponseEapSimUmtsAuthParams ¶ms,
+Return<void> StaNetwork::sendNetworkEapSimUmtsAuthResponse(
+ const ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams ¶ms,
sendNetworkEapSimUmtsAuthResponse_cb _hidl_cb)
{
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -971,7 +985,7 @@
HIDL_RETURN(SupplicantStatusCode::SUCCESS);
}
-Return<void> Network::sendNetworkEapIdentityResponse(
+Return<void> StaNetwork::sendNetworkEapIdentityResponse(
const hidl_vec<uint8_t> &identity,
sendNetworkEapIdentityResponse_cb _hidl_cb)
{
@@ -1014,7 +1028,7 @@
* is removed, all RPC method calls on this object will
* return failure.
*/
-struct wpa_ssid *Network::retrieveNetworkPtr()
+struct wpa_ssid *StaNetwork::retrieveNetworkPtr()
{
wpa_supplicant *wpa_s = retrieveIfacePtr();
if (!wpa_s)
@@ -1027,7 +1041,7 @@
* pointer for
* this network.
*/
-struct wpa_supplicant *Network::retrieveIfacePtr()
+struct wpa_supplicant *StaNetwork::retrieveIfacePtr()
{
return wpa_supplicant_get_iface(
(struct wpa_global *)wpa_global_, ifname_.c_str());
@@ -1038,13 +1052,13 @@
*
* Returns 0 if valid, 1 otherwise.
*/
-int Network::isPskPassphraseValid(const hidl_string &psk)
+int StaNetwork::isPskPassphraseValid(const hidl_string &psk)
{
if (psk.size() <
- static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
PSK_PASSPHRASE_MIN_LEN_IN_BYTES) ||
psk.size() >
- static_cast<uint32_t>(ISupplicantNetwork::ParamSizeLimits::
+ static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
PSK_PASSPHRASE_MAX_LEN_IN_BYTES)) {
return 1;
}
@@ -1059,7 +1073,7 @@
* after params update (except
* bssid).
*/
-void Network::resetInternalStateAfterParamsUpdate()
+void StaNetwork::resetInternalStateAfterParamsUpdate()
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
@@ -1082,7 +1096,7 @@
* instance for this network.
* This function frees any existing data in these fields.
*/
-int Network::setStringFieldAndResetState(
+int StaNetwork::setStringFieldAndResetState(
const char *value, uint8_t **to_update_field, const char *hexdump_prefix)
{
return setStringFieldAndResetState(
@@ -1094,7 +1108,7 @@
* instance for this network.
* This function frees any existing data in these fields.
*/
-int Network::setStringFieldAndResetState(
+int StaNetwork::setStringFieldAndResetState(
const char *value, char **to_update_field, const char *hexdump_prefix)
{
int value_len = strlen(value);
@@ -1116,7 +1130,7 @@
* instance for this network.
* This function frees any existing data in these fields.
*/
-int Network::setStringKeyFieldAndResetState(
+int StaNetwork::setStringKeyFieldAndResetState(
const char *value, char **to_update_field, const char *hexdump_prefix)
{
int value_len = strlen(value);
@@ -1138,7 +1152,7 @@
* field in |wpa_ssid| structue instance for this network.
* This function frees any existing data in these fields.
*/
-int Network::setByteArrayFieldAndResetState(
+int StaNetwork::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)
{
@@ -1164,7 +1178,7 @@
* length field in |wpa_ssid| structue instance for this network.
* This function frees any existing data in these fields.
*/
-int Network::setByteArrayKeyFieldAndResetState(
+int StaNetwork::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)
{
diff --git a/wpa_supplicant/hidl/network.h b/wpa_supplicant/hidl/sta_network.h
similarity index 88%
rename from wpa_supplicant/hidl/network.h
rename to wpa_supplicant/hidl/sta_network.h
index 614513f..a2055c3 100644
--- a/wpa_supplicant/hidl/network.h
+++ b/wpa_supplicant/hidl/sta_network.h
@@ -7,13 +7,13 @@
* See README for more details.
*/
-#ifndef WPA_SUPPLICANT_HIDL_NETWORK_H
-#define WPA_SUPPLICANT_HIDL_NETWORK_H
+#ifndef WPA_SUPPLICANT_HIDL_STA_NETWORK_H
+#define WPA_SUPPLICANT_HIDL_STA_NETWORK_H
#include <android-base/macros.h>
-#include <android/hardware/wifi/supplicant/1.0/ISupplicantNetwork.h>
-#include <android/hardware/wifi/supplicant/1.0/ISupplicantNetworkCallback.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
+#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetworkCallback.h>
extern "C" {
#include "utils/common.h"
@@ -34,22 +34,23 @@
namespace implementation {
/**
- * Implementation of Network hidl object. Each unique hidl
+ * Implementation of StaNetwork hidl object. Each unique hidl
* object is used for control operations on a specific network
* controlled by wpa_supplicant.
*/
-class Network : public ISupplicantNetwork
+class StaNetwork : public ISupplicantStaNetwork
{
public:
- Network(
+ StaNetwork(
struct wpa_global* wpa_global, const char ifname[], int network_id);
- ~Network() override = default;
+ ~StaNetwork() override = default;
// Hidl methods exposed.
Return<void> getId(getId_cb _hidl_cb) override;
Return<void> getInterfaceName(getInterfaceName_cb _hidl_cb) override;
+ Return<void> getType(getType_cb _hidl_cb) override;
Return<void> registerCallback(
- const sp<ISupplicantNetworkCallback>& callback,
+ const sp<ISupplicantStaNetworkCallback>& callback,
registerCallback_cb _hidl_cb) override;
Return<void> setSsid(
const hidl_vec<uint8_t>& ssid, setSsid_cb _hidl_cb) override;
@@ -78,10 +79,10 @@
Return<void> setRequirePmf(
bool enable, setRequirePmf_cb _hidl_cb) override;
Return<void> setEapMethod(
- ISupplicantNetwork::EapMethod method,
+ ISupplicantStaNetwork::EapMethod method,
setEapMethod_cb _hidl_cb) override;
Return<void> setEapPhase2Method(
- ISupplicantNetwork::EapPhase2Method method,
+ ISupplicantStaNetwork::EapPhase2Method method,
setEapPhase2Method_cb _hidl_cb) override;
Return<void> setEapIdentity(
const hidl_vec<uint8_t>& identity,
@@ -129,11 +130,11 @@
Return<void> disable(disable_cb _hidl_cb) override;
Return<void> select(select_cb _hidl_cb) override;
Return<void> sendNetworkEapSimGsmAuthResponse(
- const ISupplicantNetwork::NetworkResponseEapSimGsmAuthParams&
+ const ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams&
params,
sendNetworkEapSimGsmAuthResponse_cb _hidl_cb) override;
Return<void> sendNetworkEapSimUmtsAuthResponse(
- const ISupplicantNetwork::NetworkResponseEapSimUmtsAuthParams&
+ const ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams&
params,
sendNetworkEapSimUmtsAuthResponse_cb _hidl_cb) override;
Return<void> sendNetworkEapIdentityResponse(
@@ -171,7 +172,7 @@
// Id of the network this hidl object controls.
const int network_id_;
- DISALLOW_COPY_AND_ASSIGN(Network);
+ DISALLOW_COPY_AND_ASSIGN(StaNetwork);
};
} // namespace implementation
@@ -181,4 +182,4 @@
} // namespace hardware
} // namespace android
-#endif // WPA_SUPPLICANT_HIDL_NETWORK_H
+#endif // WPA_SUPPLICANT_HIDL_STA_NETWORK_H
diff --git a/wpa_supplicant/hidl/supplicant.cpp b/wpa_supplicant/hidl/supplicant.cpp
index b9f6ce2..f32ceb9 100644
--- a/wpa_supplicant/hidl/supplicant.cpp
+++ b/wpa_supplicant/hidl/supplicant.cpp
@@ -24,88 +24,53 @@
"/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)
-{
- 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_, ifname.c_str()) != NULL) {
- HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_EXISTS, iface);
- }
-
- // 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) {
- HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, iface);
- }
- // 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);
-}
-
-Return<void> Supplicant::removeInterface(
- const hidl_string& ifname, removeInterface_cb _hidl_cb)
-{
- struct wpa_supplicant* wpa_s;
-
- wpa_s = wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
- if (!wpa_s) {
- HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_UNKNOWN);
- }
- if (wpa_supplicant_remove_iface(wpa_global_, wpa_s, 0)) {
- HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
- }
-
- HIDL_RETURN(SupplicantStatusCode::SUCCESS);
-}
-
Return<void> Supplicant::getInterface(
- const hidl_string& ifname, getInterface_cb _hidl_cb)
+ const IfaceInfo& iface_info, getInterface_cb _hidl_cb)
{
- android::sp<ISupplicantIface> iface;
-
struct wpa_supplicant* wpa_s =
- wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
+ wpa_supplicant_get_iface(wpa_global_, iface_info.name.c_str());
if (!wpa_s) {
- HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_UNKNOWN, iface);
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_IFACE_UNKNOWN, nullptr);
}
HidlManager* hidl_manager = HidlManager::getInstance();
- if (!hidl_manager ||
- hidl_manager->getIfaceHidlObjectByIfname(wpa_s->ifname, &iface)) {
- HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, iface);
- }
+ if (iface_info.type == IfaceType::P2P) {
+ android::sp<ISupplicantP2pIface> iface;
+ if (!hidl_manager ||
+ hidl_manager->getP2pIfaceHidlObjectByIfname(
+ wpa_s->ifname, &iface)) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_UNKNOWN, iface);
+ }
- HIDL_RETURN(SupplicantStatusCode::SUCCESS, iface);
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, iface);
+ } else {
+ android::sp<ISupplicantStaIface> iface;
+ if (!hidl_manager ||
+ hidl_manager->getStaIfaceHidlObjectByIfname(
+ wpa_s->ifname, &iface)) {
+ HIDL_RETURN(
+ SupplicantStatusCode::FAILURE_UNKNOWN, iface);
+ }
+
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, iface);
+ }
}
Return<void> Supplicant::listInterfaces(listInterfaces_cb _hidl_cb)
{
- std::vector<hidl_string> ifnames;
+ std::vector<ISupplicant::IfaceInfo> ifaces;
for (struct wpa_supplicant* wpa_s = wpa_global_->ifaces; wpa_s;
wpa_s = wpa_s->next) {
- ifnames.emplace_back(wpa_s->ifname);
+ if (wpa_s->global->p2p_init_wpa_s == wpa_s) {
+ ifaces.emplace_back({IfaceType::P2P, wpa_s->ifname});
+ } else {
+ ifaces.emplace_back({IfaceType::STA, wpa_s->ifname});
+ }
}
- HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifnames);
+ HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifaces);
}
Return<void> Supplicant::registerCallback(
diff --git a/wpa_supplicant/hidl/supplicant.h b/wpa_supplicant/hidl/supplicant.h
index cad4052..f4a77d9 100644
--- a/wpa_supplicant/hidl/supplicant.h
+++ b/wpa_supplicant/hidl/supplicant.h
@@ -41,12 +41,8 @@
~Supplicant() override = default;
// 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;
+ const IfaceInfo& iface_info, getInterface_cb _hidl_cb) override;
Return<void> listInterfaces(listInterfaces_cb _hidl_cb) override;
Return<void> registerCallback(
const sp<ISupplicantCallback>& callback,
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index c76b82d..6627b90 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -61,15 +61,15 @@
int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
{
- if (wpa_s->p2p_mgmt)
- return 0;
+ if (!wpa_s->p2p_mgmt) {
+ if (wpas_dbus_register_iface(wpa_s))
+ return -1;
- if (wpas_dbus_register_iface(wpa_s))
- return -1;
+ if (wpas_dbus_register_interface(wpa_s))
+ return -1;
+ }
- if (wpas_dbus_register_interface(wpa_s))
- return -1;
-
+ /* HIDL interface wants to keep track of the P2P mgmt iface. */
if (wpas_hidl_register_interface(wpa_s))
return -1;
@@ -79,15 +79,15 @@
void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
{
- if (wpa_s->p2p_mgmt)
- return;
+ if (!wpa_s->p2p_mgmt) {
+ /* unregister interface in old DBus ctrl iface */
+ wpas_dbus_unregister_iface(wpa_s);
- /* unregister interface in old DBus ctrl iface */
- wpas_dbus_unregister_iface(wpa_s);
+ /* unregister interface in new DBus ctrl iface */
+ wpas_dbus_unregister_interface(wpa_s);
+ }
- /* unregister interface in new DBus ctrl iface */
- wpas_dbus_unregister_interface(wpa_s);
-
+ /* HIDL interface wants to keep track of the P2P mgmt iface. */
wpas_hidl_unregister_interface(wpa_s);
}
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 25ec502..8cfb488 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -5225,13 +5225,15 @@
return NULL;
}
- if (iface->p2p_mgmt == 0) {
- /* Notify the control interfaces about new iface */
- if (wpas_notify_iface_added(wpa_s)) {
- wpa_supplicant_deinit_iface(wpa_s, 1, 0);
- return NULL;
- }
+ /* Notify the control interfaces about new iface */
+ if (wpas_notify_iface_added(wpa_s)) {
+ wpa_supplicant_deinit_iface(wpa_s, 1, 0);
+ return NULL;
+ }
+ /* Notify the control interfaces about new networks for non p2p mgmt
+ * ifaces. */
+ if (iface->p2p_mgmt == 0) {
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
wpas_notify_network_added(wpa_s, ssid);
}