DBus: Signal ANQP query done

Add a D-Bus signal "ANQPQueryDone" to notify of the result of an ANQP
request.

Signed-off-by: Damien Dejean <damiendejean@chromium.org>
This commit is contained in:
Damien Dejean 2024-02-20 12:12:11 +00:00 committed by Jouni Malinen
parent d71c838519
commit 2ea04435ec
7 changed files with 118 additions and 2 deletions

View file

@ -1363,6 +1363,17 @@ fi.w1.wpa_supplicant1.CreateInterface.
<dd>URL of the terms and conditions page.</dd> <dd>URL of the terms and conditions page.</dd>
</dl> </dl>
</li> </li>
<li>
<h3>ANQPQueryDone ( s : addr, s : result )</h3>
<p>Result of an ANQP query.</p>
<dl>
<dt>s : addr</dt>
<dd>Address of the BSS targeted by the query.</dd>
<dt>s : result</dt>
<dd>Determine if the request was successful. If so fields are available in BSS.</dd>
</dl>
</li>
</ul> </ul>

View file

@ -6308,3 +6308,48 @@ def test_dbus_anqp_get(dev, apdev):
bss = dev[0].get_bss(bssid) bss = dev[0].get_bss(bssid)
if 'anqp_capability_list' not in bss: if 'anqp_capability_list' not in bss:
raise Exception("Capability List ANQP-element not seen") raise Exception("Capability List ANQP-element not seen")
def test_dbus_anqp_query_done(dev, apdev):
"""D-Bus ANQP get test"""
(bus, wpa_obj, path, if_obj) = prepare_dbus(dev[0])
iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE)
bssid = apdev[0]['bssid']
params = hs20_ap_params(ssid="test-anqp")
params["hessid"] = bssid
params['mbo'] = '1'
params['mbo_cell_data_conn_pref'] = '1'
params['hs20_oper_friendly_name'] = ["eng:Example operator",
"fin:Esimerkkioperaattori"]
hapd = hostapd.add_ap(apdev[0], params)
class TestDbusANQPGet(TestDbus):
def __init__(self, bus):
TestDbus.__init__(self, bus)
self.anqp_query_done = False
def __enter__(self):
gobject.timeout_add(1, self.run_query)
gobject.timeout_add(15000, self.timeout)
self.add_signal(self.anqpQueryDone, WPAS_DBUS_IFACE,
"ANQPQueryDone")
self.loop.run()
return self
def anqpQueryDone(self, addr, result):
logger.debug("anqpQueryDone: addr=%s result=%s" % (addr, result))
if addr == bssid and "SUCCESS" in result:
self.anqp_query_done = True
def run_query(self, *args):
dev[0].scan_for_bss(bssid, freq="2412", force_scan=True)
iface.ANQPGet({"addr": bssid,
"ids": dbus.Array([257], dbus.Signature("q"))})
return False
def success(self):
return self.anqp_query_done
with TestDbusANQPGet(bus) as t:
if not t.success():
raise Exception("Expected signals not seen")

View file

@ -1023,6 +1023,40 @@ void wpas_dbus_signal_interworking_select_done(struct wpa_supplicant *wpa_s)
dbus_message_unref(msg); dbus_message_unref(msg);
} }
void wpas_dbus_signal_anqp_query_done(struct wpa_supplicant *wpa_s,
const u8 *dst, const char *result)
{
struct wpas_dbus_priv *iface;
DBusMessage *msg;
DBusMessageIter iter;
char addr[WPAS_DBUS_OBJECT_PATH_MAX], *bssid;
os_snprintf(addr, WPAS_DBUS_OBJECT_PATH_MAX, MACSTR, MAC2STR(dst));
bssid = addr;
iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
if (!iface || !wpa_s->dbus_new_path)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
WPAS_DBUS_NEW_IFACE_INTERFACE,
"ANQPQueryDone");
if (!msg)
return;
dbus_message_iter_init_append(msg, &iter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &bssid) ||
!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &result))
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL);
dbus_message_unref(msg);
}
#endif /* CONFIG_INTERWORKING */ #endif /* CONFIG_INTERWORKING */
@ -4310,6 +4344,13 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
END_ARGS END_ARGS
} }
}, },
{"ANQPQueryDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
{
{ "addr", "s", ARG_OUT },
{ "result", "s", ARG_OUT },
END_ARGS
}
},
#endif /* CONFIG_INTERWORKING */ #endif /* CONFIG_INTERWORKING */
#ifdef CONFIG_HS20 #ifdef CONFIG_HS20
{ "HS20TermsAndConditions", WPAS_DBUS_NEW_IFACE_INTERFACE, { "HS20TermsAndConditions", WPAS_DBUS_NEW_IFACE_INTERFACE,

View file

@ -279,6 +279,8 @@ void wpas_dbus_signal_interworking_ap_added(struct wpa_supplicant *wpa_s,
int bh, int bss_load, int bh, int bss_load,
int conn_capab); int conn_capab);
void wpas_dbus_signal_interworking_select_done(struct wpa_supplicant *wpa_s); void wpas_dbus_signal_interworking_select_done(struct wpa_supplicant *wpa_s);
void wpas_dbus_signal_anqp_query_done(struct wpa_supplicant *wpa_s,
const u8 *dst, const char *result);
void wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
const char *url); const char *url);
@ -652,6 +654,12 @@ void wpas_dbus_signal_interworking_select_done(struct wpa_supplicant *wpa_s)
{ {
} }
static inline
void wpas_dbus_signal_anqp_query_done(struct wpa_supplicant *wpa_s,
const u8 *dst, const char *result)
{
}
static inline static inline
void wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s, void wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
const char *url) const char *url)

View file

@ -3202,8 +3202,7 @@ out_parse_done:
hs20_notify_parse_done(wpa_s); hs20_notify_parse_done(wpa_s);
#endif /* CONFIG_HS20 */ #endif /* CONFIG_HS20 */
out: out:
wpa_msg(wpa_s, MSG_INFO, ANQP_QUERY_DONE "addr=" MACSTR " result=%s", wpas_notify_anqp_query_done(wpa_s, dst, anqp_result);
MAC2STR(dst), anqp_result);
} }

View file

@ -1013,6 +1013,16 @@ void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
wpas_dbus_signal_interworking_select_done(wpa_s); wpas_dbus_signal_interworking_select_done(wpa_s);
} }
void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s,
const u8 *dst, const char *result)
{
wpa_msg(wpa_s, MSG_INFO, ANQP_QUERY_DONE "addr=" MACSTR " result=%s",
MAC2STR(dst), result);
wpas_dbus_signal_anqp_query_done(wpa_s, dst, result);
}
#endif /* CONFIG_INTERWORKING */ #endif /* CONFIG_INTERWORKING */

View file

@ -166,6 +166,8 @@ void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
const char *type, int bh, int bss_load, const char *type, int bh, int bss_load,
int conn_capab); int conn_capab);
void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s); void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s);
void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s,
const u8 *dst, const char *result);
void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s, void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
struct rsn_pmksa_cache_entry *entry); struct rsn_pmksa_cache_entry *entry);
void wpas_notify_signal_change(struct wpa_supplicant *wpa_s); void wpas_notify_signal_change(struct wpa_supplicant *wpa_s);