[DPP R2] Added support for DPP R2 events
Added support for DPP R2 events that provide additional
details about the onboarding process of a remote enrollee.
Specifically, DPP R2 configurator waits for response from
the enrollee, which reports back the SSID, tried channels
and band support in case it cannot find the AP. When it
reports success, then it means that it is acutally connected.
Bug: 139381558
Test: Manual tests with DPP R1 and R2 enrollees
Test: atest DppManagerTest
Test: act.py -c ../WifiDppConfig.json -tc WifiDppTest
Change-Id: I0eba7fcca016ebbdbbd1bd5b44f02837fd982466
diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c
index dee8e28..a436930 100644
--- a/wpa_supplicant/dpp_supplicant.c
+++ b/wpa_supplicant/dpp_supplicant.c
@@ -1435,6 +1435,7 @@
wpa_printf(MSG_DEBUG,
"DPP: Timeout while waiting for Configuration Result");
wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONF_FAILED);
+ wpas_notify_dpp_configuration_failure(wpa_s);
dpp_auth_deinit(auth);
wpa_s->dpp_auth = NULL;
}
@@ -1452,6 +1453,7 @@
wpa_printf(MSG_DEBUG,
"DPP: Timeout while waiting for Connection Status Result");
wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONN_STATUS_RESULT "timeout");
+ wpas_notify_dpp_timeout(wpa_s);
wpas_dpp_listen_stop(wpa_s);
dpp_auth_deinit(auth);
wpa_s->dpp_auth = NULL;
@@ -1485,6 +1487,7 @@
wpa_msg(wpa_s, MSG_INFO,
DPP_EVENT_CONF_SENT "wait_conn_status=1");
wpa_printf(MSG_DEBUG, "DPP: Wait for Connection Status Result");
+ wpas_notify_dpp_config_accepted(wpa_s);
eloop_cancel_timeout(wpas_dpp_config_result_wait_timeout,
wpa_s, NULL);
auth->waiting_conn_status_result = 1;
@@ -1506,7 +1509,7 @@
}
else {
wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONF_FAILED);
- wpas_notify_dpp_configuration_failure(wpa_s);
+ wpas_notify_dpp_config_rejected(wpa_s);
}
dpp_auth_deinit(auth);
wpa_s->dpp_auth = NULL;
@@ -1538,6 +1541,8 @@
"result=%d ssid=%s channel_list=%s",
status, wpa_ssid_txt(ssid, ssid_len),
channel_list ? channel_list : "N/A");
+ wpas_notify_dpp_conn_status(wpa_s, status, wpa_ssid_txt(ssid, ssid_len),
+ channel_list, auth->band_list, auth->band_list_size);
os_free(channel_list);
offchannel_send_action_done(wpa_s);
wpas_dpp_listen_stop(wpa_s);
@@ -2199,6 +2204,7 @@
if (ok && auth->peer_version >= 2 &&
auth->conf_resp_status == DPP_STATUS_OK) {
wpa_printf(MSG_DEBUG, "DPP: Wait for Configuration Result");
+ wpas_notify_dpp_config_sent_wait_response(wpa_s);
auth->waiting_conf_result = 1;
auth->conf_resp = NULL;
wpabuf_free(resp);
diff --git a/wpa_supplicant/hidl/1.3/hidl.cpp b/wpa_supplicant/hidl/1.3/hidl.cpp
index a04126d..a3efde4 100644
--- a/wpa_supplicant/hidl/1.3/hidl.cpp
+++ b/wpa_supplicant/hidl/1.3/hidl.cpp
@@ -19,17 +19,20 @@
#include "utils/common.h"
#include "utils/eloop.h"
#include "utils/includes.h"
+#include "dpp.h"
}
using android::hardware::configureRpcThreadpool;
using android::hardware::handleTransportPoll;
using android::hardware::setupTransportPolling;
-using android::hardware::wifi::supplicant::V1_2::DppFailureCode;
-using android::hardware::wifi::supplicant::V1_2::DppProgressCode;
+using android::hardware::wifi::supplicant::V1_3::DppFailureCode;
+using android::hardware::wifi::supplicant::V1_3::DppProgressCode;
+using android::hardware::wifi::supplicant::V1_3::DppSuccessCode;
using android::hardware::wifi::supplicant::V1_3::implementation::HidlManager;
static void wpas_hidl_notify_dpp_failure(struct wpa_supplicant *wpa_s, DppFailureCode code);
static void wpas_hidl_notify_dpp_progress(struct wpa_supplicant *wpa_s, DppProgressCode code);
+static void wpas_hidl_notify_dpp_success(struct wpa_supplicant *wpa_s, DppSuccessCode code);
void wpas_hidl_sock_handler(
int sock, void * /* eloop_ctx */, void * /* sock_ctx */)
@@ -667,84 +670,56 @@
void wpas_hidl_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
-
- wpa_printf(
- MSG_DEBUG,
- "Notifying DPP configuration sent");
-
- HidlManager *hidl_manager = HidlManager::getInstance();
- if (!hidl_manager)
- return;
-
- hidl_manager->notifyDppConfigSent(wpa_s);
+ wpas_hidl_notify_dpp_success(wpa_s, DppSuccessCode::CONFIGURATION_SENT);
}
/* DPP Progress notifications */
void wpas_hidl_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
-
wpas_hidl_notify_dpp_progress(wpa_s, DppProgressCode::AUTHENTICATION_SUCCESS);
}
void wpas_hidl_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
-
wpas_hidl_notify_dpp_progress(wpa_s, DppProgressCode::RESPONSE_PENDING);
}
/* DPP Failure notifications */
void wpas_hidl_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
-
wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::NOT_COMPATIBLE);
}
void wpas_hidl_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
+ wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::AUTHENTICATION);
}
void wpas_hidl_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
-
wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::CONFIGURATION);
}
void wpas_hidl_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
-
wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::TIMEOUT);
}
void wpas_hidl_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
-
wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::AUTHENTICATION);
}
void wpas_hidl_notify_dpp_fail(struct wpa_supplicant *wpa_s)
{
- if (!wpa_s)
- return;
-
wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::FAILURE);
}
+void wpas_hidl_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
+{
+ wpas_hidl_notify_dpp_progress(wpa_s, DppProgressCode::CONFIGURATION_SENT_WAITING_RESPONSE);
+}
+
/* DPP notification helper functions */
static void wpas_hidl_notify_dpp_failure(struct wpa_supplicant *wpa_s, DppFailureCode code)
{
@@ -778,6 +753,97 @@
hidl_manager->notifyDppProgress(wpa_s, code);
}
+void wpas_hidl_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
+{
+ wpas_hidl_notify_dpp_progress(wpa_s, DppProgressCode::CONFIGURATION_ACCEPTED);
+}
+
+static void wpas_hidl_notify_dpp_config_applied(struct wpa_supplicant *wpa_s)
+{
+ wpas_hidl_notify_dpp_success(wpa_s, DppSuccessCode::CONFIGURATION_APPLIED);
+}
+
+static void wpas_hidl_notify_dpp_success(struct wpa_supplicant *wpa_s, DppSuccessCode code)
+{
+ if (!wpa_s)
+ return;
+
+ wpa_printf(
+ MSG_DEBUG,
+ "Notifying DPP progress event %d", code);
+
+ HidlManager *hidl_manager = HidlManager::getInstance();
+ if (!hidl_manager)
+ return;
+
+ hidl_manager->notifyDppSuccess(wpa_s, code);
+}
+
+void wpas_hidl_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
+{
+ wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::CONFIGURATION_REJECTED);
+}
+
+static void wpas_hidl_notify_dpp_no_ap_failure(struct wpa_supplicant *wpa_s,
+ const char *ssid, const char *channel_list, unsigned short band_list[],
+ int size)
+{
+ if (!wpa_s)
+ return;
+
+ wpa_printf(MSG_DEBUG,
+ "Notifying DPP NO AP event for SSID %s\nTried channels: %s",
+ ssid ? ssid : "N/A", channel_list ? channel_list : "N/A");
+
+ HidlManager *hidl_manager = HidlManager::getInstance();
+ if (!hidl_manager)
+ return;
+
+ hidl_manager->notifyDppFailure(wpa_s, DppFailureCode::CANNOT_FIND_NETWORK,
+ ssid, channel_list, band_list, size);
+}
+
+void wpas_hidl_notify_dpp_enrollee_auth_failure(struct wpa_supplicant *wpa_s,
+ const char *ssid, unsigned short band_list[], int size)
+{
+ if (!wpa_s)
+ return;
+
+ wpa_printf(MSG_DEBUG,
+ "Notifying DPP Enrollee authentication failure, SSID %s",
+ ssid ? ssid : "N/A");
+
+ HidlManager *hidl_manager = HidlManager::getInstance();
+ if (!hidl_manager)
+ return;
+
+ hidl_manager->notifyDppFailure(wpa_s, DppFailureCode::ENROLLEE_AUTHENTICATION,
+ ssid, NULL, band_list, size);
+}
+
+
+void wpas_hidl_notify_dpp_conn_status(struct wpa_supplicant *wpa_s, enum dpp_status_error status,
+ const char *ssid, const char *channel_list, unsigned short band_list[], int size)
+{
+ switch (status)
+ {
+ case DPP_STATUS_OK:
+ wpas_hidl_notify_dpp_config_applied(wpa_s);
+ break;
+
+ case DPP_STATUS_NO_AP:
+ wpas_hidl_notify_dpp_no_ap_failure(wpa_s, ssid, channel_list, band_list, size);
+ break;
+
+ case DPP_STATUS_AUTH_FAILURE:
+ wpas_hidl_notify_dpp_enrollee_auth_failure(wpa_s, ssid, band_list, size);
+ break;
+
+ default:
+ break;
+ }
+}
+
void wpas_hidl_notify_pmk_cache_added(
struct wpa_supplicant *wpa_s,
struct rsn_pmksa_cache_entry *pmksa_entry)
diff --git a/wpa_supplicant/hidl/1.3/hidl.h b/wpa_supplicant/hidl/1.3/hidl.h
index ca9980b..0db90a1 100644
--- a/wpa_supplicant/hidl/1.3/hidl.h
+++ b/wpa_supplicant/hidl/1.3/hidl.h
@@ -111,6 +111,12 @@
void wpas_hidl_notify_dpp_timeout(struct wpa_supplicant *wpa_s);
void wpas_hidl_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s);
void wpas_hidl_notify_dpp_fail(struct wpa_supplicant *wpa_s);
+ void wpas_hidl_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s);
+ void wpas_hidl_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s);
+ void wpas_hidl_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s);
+ void wpas_hidl_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
+ enum dpp_status_error status, const char *ssid,
+ const char *channel_list, unsigned short band_list[], int size);
void wpas_hidl_notify_pmk_cache_added(
struct wpa_supplicant *wpas, struct rsn_pmksa_cache_entry *pmksa_entry);
#else // CONFIG_CTRL_IFACE_HIDL
@@ -241,6 +247,14 @@
{}
static void wpas_hidl_notify_dpp_failure(struct wpa_supplicant *wpa_s)
{}
+void wpas_hidl_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
+{}
+void wpas_hidl_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
+{}
+void wpas_hidl_notify_dpp_config_applied(struct wpa_supplicant *wpa_s)
+{}
+void wpas_hidl_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
+{}
static void wpas_hidl_notify_pmk_cache_added(struct wpa_supplicant *wpas,
struct rsn_pmksa_cache_entry *pmksa_entry)
{}
diff --git a/wpa_supplicant/hidl/1.3/hidl_manager.cpp b/wpa_supplicant/hidl/1.3/hidl_manager.cpp
index 18c1c89..8b2be11 100644
--- a/wpa_supplicant/hidl/1.3/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/1.3/hidl_manager.cpp
@@ -402,7 +402,6 @@
namespace supplicant {
namespace V1_3 {
namespace implementation {
-
using V1_0::ISupplicantStaIfaceCallback;
HidlManager *HidlManager::instance_ = NULL;
@@ -1477,7 +1476,9 @@
/* Unsupported AKM */
wpa_printf(MSG_ERROR, "DPP: Error: Unsupported AKM 0x%X",
config->key_mgmt);
- notifyDppFailure(wpa_s, DppFailureCode::NOT_SUPPORTED);
+ notifyDppFailure(wpa_s,
+ android::hardware::wifi::supplicant::V1_3::DppFailureCode
+ ::NOT_SUPPORTED);
return;
}
@@ -1515,13 +1516,29 @@
* @param ifname Interface name
* @param code Status code
*/
-void HidlManager::notifyDppFailure(struct wpa_supplicant *wpa_s, DppFailureCode code)
-{
+void HidlManager::notifyDppFailure(struct wpa_supplicant *wpa_s,
+ android::hardware::wifi::supplicant::V1_3::DppFailureCode code) {
std::string hidl_ifname = wpa_s->ifname;
- callWithEachStaIfaceCallback_1_2(hidl_ifname,
- std::bind(&V1_2::ISupplicantStaIfaceCallback::onDppFailure,
- std::placeholders::_1, code));
+ notifyDppFailure(wpa_s, code, NULL, NULL, NULL, 0);
+}
+
+/**
+ * Notify listener about a DPP failure event
+ *
+ * @param ifname Interface name
+ * @param code Status code
+ */
+void HidlManager::notifyDppFailure(struct wpa_supplicant *wpa_s,
+ android::hardware::wifi::supplicant::V1_3::DppFailureCode code,
+ const char *ssid, const char *channel_list, unsigned short band_list[],
+ int size) {
+ std::string hidl_ifname = wpa_s->ifname;
+ std::vector<uint16_t> band_list_vec(band_list, band_list + size);
+
+ callWithEachStaIfaceCallback_1_3(hidl_ifname,
+ std::bind(&V1_3::ISupplicantStaIfaceCallback::onDppFailure_1_3,
+ std::placeholders::_1, code, ssid, channel_list, band_list_vec));
}
/**
@@ -1530,12 +1547,27 @@
* @param ifname Interface name
* @param code Status code
*/
-void HidlManager::notifyDppProgress(struct wpa_supplicant *wpa_s, DppProgressCode code)
+void HidlManager::notifyDppProgress(struct wpa_supplicant *wpa_s,
+ android::hardware::wifi::supplicant::V1_3::DppProgressCode code) {
+ std::string hidl_ifname = wpa_s->ifname;
+
+ callWithEachStaIfaceCallback_1_3(hidl_ifname,
+ std::bind(&V1_3::ISupplicantStaIfaceCallback::onDppProgress_1_3,
+ std::placeholders::_1, code));
+}
+
+/**
+ * Notify listener about a DPP success event
+ *
+ * @param ifname Interface name
+ * @param code Status code
+ */
+void HidlManager::notifyDppSuccess(struct wpa_supplicant *wpa_s, DppSuccessCode code)
{
std::string hidl_ifname = wpa_s->ifname;
- callWithEachStaIfaceCallback_1_2(hidl_ifname,
- std::bind(&V1_2::ISupplicantStaIfaceCallback::onDppProgress,
+ callWithEachStaIfaceCallback_1_3(hidl_ifname,
+ std::bind(&V1_3::ISupplicantStaIfaceCallback::onDppSuccess,
std::placeholders::_1, code));
}
@@ -1929,6 +1961,23 @@
/**
* Helper function to invoke the provided callback method on all the
+ * registered V1.3 interface callback hidl objects for the specified
+ * |ifname|.
+ *
+ * @param ifname Name of the corresponding interface.
+ * @param method Pointer to the required hidl method from
+ * |V1_3::ISupplicantIfaceCallback|.
+ */
+void HidlManager::callWithEachStaIfaceCallback_1_3(
+ const std::string &ifname,
+ const std::function<
+ Return<void>(android::sp<V1_3::ISupplicantStaIfaceCallback>)> &method)
+{
+ callWithEachIfaceCallbackDerived(ifname, method, sta_iface_callbacks_map_);
+}
+
+/**
+ * Helper function to invoke the provided callback method on all the
* registered derived interface callback hidl objects for the specified
* |ifname|.
*
diff --git a/wpa_supplicant/hidl/1.3/hidl_manager.h b/wpa_supplicant/hidl/1.3/hidl_manager.h
index 1040b0c..3394e4b 100644
--- a/wpa_supplicant/hidl/1.3/hidl_manager.h
+++ b/wpa_supplicant/hidl/1.3/hidl_manager.h
@@ -133,8 +133,15 @@
void notifyDppConfigReceived(struct wpa_supplicant *wpa_s,
struct wpa_ssid *config);
void notifyDppConfigSent(struct wpa_supplicant *wpa_s);
- void notifyDppFailure(struct wpa_supplicant *wpa_s, DppFailureCode code);
- void notifyDppProgress(struct wpa_supplicant *wpa_s, DppProgressCode code);
+ void notifyDppSuccess(struct wpa_supplicant *wpa_s, DppSuccessCode code);
+ void notifyDppFailure(struct wpa_supplicant *wpa_s,
+ android::hardware::wifi::supplicant::V1_3::DppFailureCode code);
+ void notifyDppFailure(struct wpa_supplicant *wpa_s,
+ android::hardware::wifi::supplicant::V1_3::DppFailureCode code,
+ const char *ssid, const char *channel_list, unsigned short band_list[],
+ int size);
+ void notifyDppProgress(struct wpa_supplicant *wpa_s,
+ android::hardware::wifi::supplicant::V1_3::DppProgressCode code);
void notifyPmkCacheAdded(struct wpa_supplicant *wpa_s,
struct rsn_pmksa_cache_entry *pmksa_entry);
@@ -210,6 +217,10 @@
const std::string &ifname,
const std::function<android::hardware::Return<void>(
android::sp<V1_2::ISupplicantStaIfaceCallback>)> &method);
+ void callWithEachStaIfaceCallback_1_3(
+ const std::string &ifname,
+ const std::function<android::hardware::Return<void>(
+ android::sp<V1_3::ISupplicantStaIfaceCallback>)> &method);
template <class CallbackTypeDerived>
void callWithEachStaIfaceCallbackDerived(
const std::string &ifname,
diff --git a/wpa_supplicant/hidl/1.3/sta_iface.cpp b/wpa_supplicant/hidl/1.3/sta_iface.cpp
index c9e5305..9bea68f 100644
--- a/wpa_supplicant/hidl/1.3/sta_iface.cpp
+++ b/wpa_supplicant/hidl/1.3/sta_iface.cpp
@@ -1288,6 +1288,11 @@
cmd += " conf=";
cmd += role;
+ if (net_role == DppNetRole::STA) {
+ /* DPP R2 connection status request */
+ cmd += " conn_status=1";
+ }
+
wpa_printf(MSG_DEBUG,
"DPP initiator command: %s", cmd.c_str());
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 2ebe034..206b488 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1165,6 +1165,36 @@
#endif /* CONFIG_DPP */
}
+void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
+{
+#ifdef CONFIG_DPP2
+ wpas_hidl_notify_dpp_config_sent_wait_response(wpa_s);
+#endif /* CONFIG_DPP2 */
+}
+
+void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
+{
+#ifdef CONFIG_DPP2
+ wpas_hidl_notify_dpp_config_accepted(wpa_s);
+#endif /* CONFIG_DPP2 */
+}
+
+void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
+ enum dpp_status_error status, const char *ssid,
+ const char *channel_list, unsigned short band_list[], int size)
+{
+#ifdef CONFIG_DPP2
+ wpas_hidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
+#endif /* CONFIG_DPP2 */
+}
+
+void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
+{
+#ifdef CONFIG_DPP2
+ wpas_hidl_notify_dpp_config_rejected(wpa_s);
+#endif /* CONFIG_DPP2 */
+}
+
void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
struct rsn_pmksa_cache_entry *entry)
{
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index c78ca68..e9e39ee 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -12,6 +12,7 @@
#include "p2p/p2p.h"
#include "bss.h"
#include "rsn_supp/pmksa_cache.h"
+#include "dpp.h"
struct wps_credential;
struct wps_event_m2d;
@@ -184,6 +185,12 @@
void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s);
void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s);
void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s);
+void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s);
+void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
+ enum dpp_status_error status, const char *ssid,
+ const char *channel_list, unsigned short band_list[], int size);
+void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s);
+void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s);
void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
struct rsn_pmksa_cache_entry *entry);