notify.c revision 04949598a23f501be6eec21697465fd46a28840a
18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/*
28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpa_supplicant - Event notifications
38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
5c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * This software may be distributed under the terms of the BSD license.
6c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * See README for more details.
78d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
88d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "utils/includes.h"
108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "utils/common.h"
128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "common/wpa_ctrl.h"
138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "config.h"
148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "wpa_supplicant_i.h"
158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "wps_supplicant.h"
168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "dbus/dbus_common.h"
178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "dbus/dbus_old.h"
188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "dbus/dbus_new.h"
191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#include "rsn_supp/wpa.h"
208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "driver_i.h"
218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "scan.h"
228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "p2p_supplicant.h"
238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "sme.h"
248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "notify.h"
258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint wpas_notify_supplicant_initialized(struct wpa_global *global)
278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_DBUS
298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (global->params.dbus_ctrl_interface) {
308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		global->dbus = wpas_dbus_init(global);
318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		if (global->dbus == NULL)
328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			return -1;
338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_DBUS */
358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_supplicant_deinitialized(struct wpa_global *global)
418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_DBUS
438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (global->dbus)
448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpas_dbus_deinit(global->dbus);
458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_DBUS */
468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpas_dbus_register_iface(wpa_s))
528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpas_dbus_register_interface(wpa_s))
558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* unregister interface in old DBus ctrl iface */
648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_unregister_iface(wpa_s);
658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* unregister interface in new DBus ctrl iface */
678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_unregister_interface(wpa_s);
688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			       enum wpa_states new_state,
738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			       enum wpa_states old_state)
748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* notify the old DBus API */
768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt						old_state);
788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* notify the new DBus API */
808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_P2P
838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (new_state == WPA_COMPLETED)
848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpas_p2p_notif_connected(wpa_s);
8504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpas_p2p_notif_disconnected(wpa_s);
878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_P2P */
888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	sme_state_changed(wpa_s);
908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef ANDROID
928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
93f20a4432808cee548326c4b35c83071ca576a239Irfan Sheriff		     "id=%d state=%d BSSID=" MACSTR " SSID=%s",
948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		     wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
95f20a4432808cee548326c4b35c83071ca576a239Irfan Sheriff		     new_state,
96f20a4432808cee548326c4b35c83071ca576a239Irfan Sheriff		     MAC2STR(wpa_s->pending_bssid),
975b5fb02b225c5c05a4477bef58bdaceede5d68dcandy		     wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
985b5fb02b225c5c05a4477bef58bdaceede5d68dcandy		     wpa_ssid_txt(wpa_s->current_ssid->ssid,
991029477547084d210cb810e8e5463c628972b315Irfan Sheriff		     wpa_s->current_ssid->ssid_len): "");
1008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* ANDROID */
1018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
10404949598a23f501be6eec21697465fd46a28840aDmitry Shmidtvoid wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
10504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt{
10604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
10704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt}
10804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
10904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
1108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
1118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
1138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
1178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
1198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
1238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
1258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
1298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
1318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
1358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					 struct wpa_ssid *ssid)
1368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
1388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
1428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				  struct wpa_ssid *ssid)
1438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_network_selected(wpa_s, ssid->id);
1458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1481f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidtvoid wpas_notify_network_request(struct wpa_supplicant *wpa_s,
1491f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				 struct wpa_ssid *ssid,
1501f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				 enum wpa_ctrl_req_type rtype,
1511f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				 const char *default_txt)
1521f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt{
1531f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
1541f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt}
1551f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
1561f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
1578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_scanning(struct wpa_supplicant *wpa_s)
1588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* notify the old DBus API */
1608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_supplicant_dbus_notify_scanning(wpa_s);
1618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* notify the new DBus API */
1638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
1648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
1688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_scan_done(wpa_s, success);
1708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
1748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* notify the old DBus API */
1768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_supplicant_dbus_notify_scan_results(wpa_s);
1778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_wps_notify_scan_results(wpa_s);
1798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
1838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				const struct wps_credential *cred)
1848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS
1868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* notify the old DBus API */
1878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
1888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* notify the new DBus API */
1898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_wps_cred(wpa_s, cred);
1908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */
1918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
1958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			       struct wps_event_m2d *m2d)
1968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS
1988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
1998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */
2008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
2048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				struct wps_event_fail *fail)
2058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS
2078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_wps_event_fail(wpa_s, fail);
2088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */
2098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
2138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS
2158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_wps_event_success(wpa_s);
2168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */
2178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_network_added(struct wpa_supplicant *wpa_s,
2218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			       struct wpa_ssid *ssid)
2228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
22375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
22475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * Networks objects created during any P2P activities should not be
22575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * exposed out. They might/will confuse certain non-P2P aware
22675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * applications since these network objects won't behave like
22775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * regular ones.
22875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
22975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s->global->p2p_group_formation != wpa_s)
23075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpas_dbus_register_network(wpa_s, ssid);
23175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
23275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
23375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
23475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
23575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					struct wpa_ssid *ssid)
23675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
237c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt#ifdef CONFIG_P2P
23875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_register_persistent_group(wpa_s, ssid);
239c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt#endif /* CONFIG_P2P */
24075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
24175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
24275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
24375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
24475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					  struct wpa_ssid *ssid)
24575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
246c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt#ifdef CONFIG_P2P
24775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
248c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt#endif /* CONFIG_P2P */
2498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
2538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				 struct wpa_ssid *ssid)
2548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2551f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (wpa_s->wpa)
2561f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
25775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s->global->p2p_group_formation != wpa_s)
25875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpas_dbus_unregister_network(wpa_s, ssid->id);
2591f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef CONFIG_P2P
2601f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	wpas_p2p_network_removed(wpa_s, ssid);
2611f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_P2P */
2628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
2668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   u8 bssid[], unsigned int id)
2678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_register_bss(wpa_s, bssid, id);
2698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
2708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		     id, MAC2STR(bssid));
2718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
2758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			     u8 bssid[], unsigned int id)
2768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_unregister_bss(wpa_s, bssid, id);
2788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
2798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		     id, MAC2STR(bssid));
2808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
2848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				  unsigned int id)
2858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
2878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
2918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				    unsigned int id)
2928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
2948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					  id);
2958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
2998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				     unsigned int id)
3008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
3028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					  id);
3038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
3078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				  unsigned int id)
3088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
3108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
3148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				   unsigned int id)
3158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
3178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
3218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				   unsigned int id)
3228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
3248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
3288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				 unsigned int id)
3298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
3348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				   unsigned int id)
3358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
3378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
3418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				   unsigned int id)
3428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
3448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
3488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_blob_added(wpa_s, name);
3508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
3548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_blob_removed(wpa_s, name);
3568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_debug_level_changed(struct wpa_global *global)
3608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_debug_level_changed(global);
3628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_debug_timestamp_changed(struct wpa_global *global)
3668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_debug_timestamp_changed(global);
3688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_debug_show_keys_changed(struct wpa_global *global)
3728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_debug_show_keys_changed(global);
3748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_suspend(struct wpa_global *global)
3788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpa_supplicant *wpa_s;
3808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_get_time(&global->suspend_time);
3828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_DEBUG, "System suspend notification");
3838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
3848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_drv_suspend(wpa_s);
3858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_resume(struct wpa_global *global)
3898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct os_time now;
3918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	int slept;
3928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpa_supplicant *wpa_s;
3938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (global->suspend_time.sec == 0)
3958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		slept = -1;
3968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	else {
3978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		os_get_time(&now);
3988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		slept = now.sec - global->suspend_time.sec;
3998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
4008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
4018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		   slept);
4028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
4048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_drv_resume(wpa_s);
4058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		if (wpa_s->wpa_state == WPA_DISCONNECTED)
4068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			wpa_supplicant_req_scan(wpa_s, 0, 100000);
4078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
4088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_P2P
4128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
4148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				  const u8 *dev_addr, int new_device)
4158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
41675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (new_device) {
41775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		/* Create the new peer object */
41875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpas_dbus_register_peer(wpa_s, dev_addr);
41975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
42075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
42175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Notify a new peer has been detected*/
42275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
4238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
4278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				 const u8 *dev_addr)
4288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
42975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_unregister_peer(wpa_s, dev_addr);
43075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
43175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Create signal on interface object*/
43275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
4338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
4378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				   const struct wpa_ssid *ssid,
4388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				   const char *role)
4398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
44075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_unregister_p2p_group(wpa_s, ssid);
44175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
44275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_group_removed(wpa_s, role);
4438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
4478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				const u8 *src, u16 dev_passwd_id)
4488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
44975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id);
4508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4531f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidtvoid wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
4541f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				      struct p2p_go_neg_results *res)
4558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
4561f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
4578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
4618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				       int status, const u8 *bssid)
4628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
46375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
4648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
4688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				int freq, const u8 *sa, u8 dialog_token,
4698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				u16 update_indic, const u8 *tlvs,
4708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				size_t tlvs_len)
4718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
47275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
47375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					update_indic, tlvs, tlvs_len);
4748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
4788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				 const u8 *sa, u16 update_indic,
4798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				 const u8 *tlvs, size_t tlvs_len)
4808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
48175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
48275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					 tlvs, tlvs_len);
48375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
48475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
48575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
48675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
48775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_notify_p2p_provision_discovery - Notification of provision discovery
48875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @dev_addr: Who sent the request or responded to our request.
48975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @request: Will be 1 if request, 0 for response.
49075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @status: Valid only in case of response (0 in case of success)
49175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @config_methods: WPS config methods
49275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
49375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
49475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * This can be used to notify:
49575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * - Requests or responses
49675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * - Various config methods
49775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * - Failure condition in case of response
49875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
49975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
50075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					 const u8 *dev_addr, int request,
50175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					 enum p2p_prov_disc_status status,
50275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					 u16 config_methods,
50375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					 unsigned int generated_pin)
50475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
50575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
50675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen						 status, config_methods,
50775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen						 generated_pin);
50875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
50975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
51075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
51175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
51275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				   struct wpa_ssid *ssid, int network_id,
51375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				   int client)
51475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
51575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Notify a group has been started */
51675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_register_p2p_group(wpa_s, ssid);
51775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
51875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
51975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
52075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
52175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
52275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
52375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				struct wps_event_fail *fail)
52475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
52575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
5268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
5278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_P2P */
5298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
5321f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					  const u8 *sta,
5331f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					  const u8 *p2p_dev_addr)
5348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
53575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_P2P
5361f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
5371f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
53875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
53975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * Register a group member object corresponding to this peer and
54075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * emit a PeerJoined signal. This will check if it really is a
54175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * P2P group.
54275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
54375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_register_p2p_groupmember(wpa_s, sta);
54475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
54575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
54675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * Create 'peer-joined' signal on group object -- will also
54775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * check P2P itself.
54875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
54975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_peer_joined(wpa_s, sta);
55075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /* CONFIG_P2P */
5518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
5528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
5558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					    const u8 *sta)
5568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
55775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_P2P
55875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
55975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * Unregister a group member object corresponding to this peer
56075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * if this is a P2P group.
56175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
56275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_unregister_p2p_groupmember(wpa_s, sta);
56375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
56475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
56575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * Create 'peer-disconnected' signal on group object if this
56675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * is a P2P group.
56775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
56875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_p2p_peer_disconnected(wpa_s, sta);
56975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /* CONFIG_P2P */
5708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
5718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
5741f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				const u8 *mac_addr, int authorized,
5751f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				const u8 *p2p_dev_addr)
5768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
5778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (authorized)
5781f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
5798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	else
5808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr);
5818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
582c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
583c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
584c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidtvoid wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
585c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt			       const char *subject, const char *cert_hash,
586c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt			       const struct wpabuf *cert)
587c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt{
588c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
589c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		"depth=%d subject='%s'%s%s",
590c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		depth, subject,
591c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		cert_hash ? " hash=" : "",
592c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		cert_hash ? cert_hash : "");
593c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
594c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	if (cert) {
595c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		char *cert_hex;
596c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		size_t len = wpabuf_len(cert) * 2 + 1;
597c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		cert_hex = os_malloc(len);
598c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		if (cert_hex) {
599c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt			wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
600c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt					 wpabuf_len(cert));
601c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt			wpa_msg_ctrl(wpa_s, MSG_INFO,
602c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt				     WPA_EVENT_EAP_PEER_CERT
603c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt				     "depth=%d subject='%s' cert=%s",
604c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt				     depth, subject, cert_hex);
605c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt			os_free(cert_hex);
606c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		}
607c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	}
608c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
609c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	/* notify the old DBus API */
610c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
611c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt						 cert_hash, cert);
612c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	/* notify the new DBus API */
613c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	wpas_dbus_signal_certification(wpa_s, depth, subject, cert_hash, cert);
614c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt}
61504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
61604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
61704949598a23f501be6eec21697465fd46a28840aDmitry Shmidtvoid wpas_notify_preq(struct wpa_supplicant *wpa_s,
61804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		      const u8 *addr, const u8 *dst, const u8 *bssid,
61904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		      const u8 *ie, size_t ie_len, u32 ssi_signal)
62004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt{
62104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_AP
62204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
62304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#endif /* CONFIG_AP */
62404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt}
62504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
62604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
62704949598a23f501be6eec21697465fd46a28840aDmitry Shmidtvoid wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
62804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			    const char *parameter)
62904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt{
63004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	wpas_dbus_signal_eap_status(wpa_s, status, parameter);
63104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt}
632