Add wpa_supplicant notification calls
This introduces a new mechanism for collecting notification calls into a single place (notify.c). As a result of this, most of the wpa_supplicant code does not need to know about dbus (etc. mechanisms that could use the notifications). Some empty placeholder functions are also added in preparation of new dbus code that needs more event notifications.
This commit is contained in:
parent
1bd3f426d3
commit
8bac466b00
11 changed files with 314 additions and 19 deletions
|
@ -49,6 +49,7 @@ MD4OBJS = # none by default
|
||||||
MD5OBJS = ../src/crypto/md5.o
|
MD5OBJS = ../src/crypto/md5.o
|
||||||
|
|
||||||
OBJS = config.o
|
OBJS = config.o
|
||||||
|
OBJS += notify.o
|
||||||
OBJS += ../src/utils/common.o
|
OBJS += ../src/utils/common.o
|
||||||
OBJS += ../src/utils/wpa_debug.o
|
OBJS += ../src/utils/wpa_debug.o
|
||||||
OBJS += ../src/utils/wpabuf.o
|
OBJS += ../src/utils/wpabuf.o
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "wps/wps.h"
|
#include "wps/wps.h"
|
||||||
#include "ibss_rsn.h"
|
#include "ibss_rsn.h"
|
||||||
#include "ap.h"
|
#include "ap.h"
|
||||||
|
#include "notify.h"
|
||||||
|
|
||||||
extern struct wpa_driver_ops *wpa_drivers[];
|
extern struct wpa_driver_ops *wpa_drivers[];
|
||||||
|
|
||||||
|
@ -958,6 +959,9 @@ static int wpa_supplicant_ctrl_iface_add_network(
|
||||||
ssid = wpa_config_add_network(wpa_s->conf);
|
ssid = wpa_config_add_network(wpa_s->conf);
|
||||||
if (ssid == NULL)
|
if (ssid == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
wpas_notify_network_added(wpa_s, ssid);
|
||||||
|
|
||||||
ssid->disabled = 1;
|
ssid->disabled = 1;
|
||||||
wpa_config_set_network_defaults(ssid);
|
wpa_config_set_network_defaults(ssid);
|
||||||
|
|
||||||
|
@ -979,8 +983,10 @@ static int wpa_supplicant_ctrl_iface_remove_network(
|
||||||
wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_NETWORK all");
|
wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_NETWORK all");
|
||||||
ssid = wpa_s->conf->ssid;
|
ssid = wpa_s->conf->ssid;
|
||||||
while (ssid) {
|
while (ssid) {
|
||||||
|
struct wpa_ssid *remove_ssid = ssid;
|
||||||
id = ssid->id;
|
id = ssid->id;
|
||||||
ssid = ssid->next;
|
ssid = ssid->next;
|
||||||
|
wpas_notify_network_removed(wpa_s, remove_ssid);
|
||||||
wpa_config_remove_network(wpa_s->conf, id);
|
wpa_config_remove_network(wpa_s->conf, id);
|
||||||
}
|
}
|
||||||
if (wpa_s->current_ssid) {
|
if (wpa_s->current_ssid) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "driver_i.h"
|
#include "driver_i.h"
|
||||||
#include "ctrl_iface_dbus.h"
|
#include "ctrl_iface_dbus.h"
|
||||||
#include "ctrl_iface_dbus_handlers.h"
|
#include "ctrl_iface_dbus_handlers.h"
|
||||||
|
#include "notify.h"
|
||||||
#include "eap_peer/eap_methods.h"
|
#include "eap_peer/eap_methods.h"
|
||||||
#include "dbus_dict_helpers.h"
|
#include "dbus_dict_helpers.h"
|
||||||
#include "ieee802_11_defs.h"
|
#include "ieee802_11_defs.h"
|
||||||
|
@ -834,6 +835,7 @@ DBusMessage * wpas_dbus_iface_add_network(DBusMessage *message,
|
||||||
"a network on this interface.");
|
"a network on this interface.");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
wpas_notify_network_added(wpa_s, ssid);
|
||||||
ssid->disabled = 1;
|
ssid->disabled = 1;
|
||||||
wpa_config_set_network_defaults(ssid);
|
wpa_config_set_network_defaults(ssid);
|
||||||
|
|
||||||
|
@ -897,6 +899,8 @@ DBusMessage * wpas_dbus_iface_remove_network(DBusMessage *message,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wpas_notify_network_removed(wpa_s, ssid);
|
||||||
|
|
||||||
if (wpa_config_remove_network(wpa_s->conf, id) < 0) {
|
if (wpa_config_remove_network(wpa_s->conf, id) < 0) {
|
||||||
reply = dbus_message_new_error(message,
|
reply = dbus_message_new_error(message,
|
||||||
WPAS_ERROR_REMOVE_NETWORK_ERROR,
|
WPAS_ERROR_REMOVE_NETWORK_ERROR,
|
||||||
|
@ -1439,8 +1443,11 @@ DBusMessage * wpas_dbus_iface_set_blobs(DBusMessage *message,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success */
|
/* Success */
|
||||||
wpa_config_remove_blob(wpa_s->conf, blob->name);
|
if (!wpa_config_remove_blob(wpa_s->conf, blob->name))
|
||||||
|
wpas_notify_blob_removed(wpa_s, blob->name);
|
||||||
wpa_config_set_blob(wpa_s->conf, blob);
|
wpa_config_set_blob(wpa_s->conf, blob);
|
||||||
|
wpas_notify_blob_added(wpa_s, blob->name);
|
||||||
|
|
||||||
wpa_dbus_dict_entry_clear(&entry);
|
wpa_dbus_dict_entry_clear(&entry);
|
||||||
}
|
}
|
||||||
wpa_dbus_dict_entry_clear(&entry);
|
wpa_dbus_dict_entry_clear(&entry);
|
||||||
|
@ -1480,6 +1487,8 @@ DBusMessage * wpas_dbus_iface_remove_blobs(DBusMessage *message,
|
||||||
|
|
||||||
if (wpa_config_remove_blob(wpa_s->conf, name) != 0)
|
if (wpa_config_remove_blob(wpa_s->conf, name) != 0)
|
||||||
err_msg = "Error removing blob.";
|
err_msg = "Error removing blob.";
|
||||||
|
else
|
||||||
|
wpas_notify_blob_removed(wpa_s, name);
|
||||||
dbus_message_iter_next(&array);
|
dbus_message_iter_next(&array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "pmksa_cache.h"
|
#include "pmksa_cache.h"
|
||||||
#include "wpa_ctrl.h"
|
#include "wpa_ctrl.h"
|
||||||
#include "eap_peer/eap.h"
|
#include "eap_peer/eap.h"
|
||||||
#include "ctrl_iface_dbus.h"
|
#include "notify.h"
|
||||||
#include "ieee802_11_defs.h"
|
#include "ieee802_11_defs.h"
|
||||||
#include "blacklist.h"
|
#include "blacklist.h"
|
||||||
#include "wpas_glue.h"
|
#include "wpas_glue.h"
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
|
static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
struct wpa_ssid *ssid;
|
struct wpa_ssid *ssid, *old_ssid;
|
||||||
|
|
||||||
if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid)
|
if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -74,9 +74,12 @@ static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
|
||||||
|
|
||||||
if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
|
if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
|
||||||
eapol_sm_invalidate_cached_session(wpa_s->eapol);
|
eapol_sm_invalidate_cached_session(wpa_s->eapol);
|
||||||
|
old_ssid = wpa_s->current_ssid;
|
||||||
wpa_s->current_ssid = ssid;
|
wpa_s->current_ssid = ssid;
|
||||||
wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
|
wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
|
||||||
wpa_supplicant_initiate_eapol(wpa_s);
|
wpa_supplicant_initiate_eapol(wpa_s);
|
||||||
|
if (old_ssid != wpa_s->current_ssid)
|
||||||
|
wpas_notify_network_changed(wpa_s);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -98,9 +101,15 @@ static void wpa_supplicant_stop_countermeasures(void *eloop_ctx,
|
||||||
|
|
||||||
void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
|
void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
|
int bssid_changed;
|
||||||
|
|
||||||
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
|
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
|
||||||
|
bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
|
||||||
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
||||||
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
|
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
|
||||||
|
if (bssid_changed)
|
||||||
|
wpas_notify_bssid_changed(wpa_s);
|
||||||
|
|
||||||
eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
|
eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
|
||||||
eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
|
eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
|
||||||
if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
|
if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
|
||||||
|
@ -636,10 +645,11 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s)
|
||||||
"empty - not posting");
|
"empty - not posting");
|
||||||
} else {
|
} else {
|
||||||
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
|
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
|
||||||
wpa_supplicant_dbus_notify_scan_results(wpa_s);
|
wpas_notify_scan_results(wpa_s);
|
||||||
wpas_wps_notify_scan_results(wpa_s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wpas_notify_scan_done(wpa_s, 1);
|
||||||
|
|
||||||
if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s)) ||
|
if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s)) ||
|
||||||
wpa_s->disconnected)
|
wpa_s->disconnected)
|
||||||
return;
|
return;
|
||||||
|
@ -870,6 +880,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
|
||||||
{
|
{
|
||||||
u8 bssid[ETH_ALEN];
|
u8 bssid[ETH_ALEN];
|
||||||
int ft_completed = wpa_ft_is_completed(wpa_s->wpa);
|
int ft_completed = wpa_ft_is_completed(wpa_s->wpa);
|
||||||
|
int bssid_changed;
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
wpa_supplicant_event_associnfo(wpa_s, data);
|
wpa_supplicant_event_associnfo(wpa_s, data);
|
||||||
|
@ -882,8 +893,12 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
|
||||||
os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0)) {
|
os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0)) {
|
||||||
wpa_msg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
|
wpa_msg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
|
||||||
MACSTR, MAC2STR(bssid));
|
MACSTR, MAC2STR(bssid));
|
||||||
|
bssid_changed = os_memcmp(wpa_s->bssid, bssid, ETH_ALEN);
|
||||||
os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
|
os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
|
||||||
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
|
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
|
||||||
|
if (bssid_changed)
|
||||||
|
wpas_notify_bssid_changed(wpa_s);
|
||||||
|
|
||||||
if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
|
if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
|
||||||
wpa_clear_keys(wpa_s, bssid);
|
wpa_clear_keys(wpa_s, bssid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "eloop.h"
|
#include "eloop.h"
|
||||||
#include "config_ssid.h"
|
#include "config_ssid.h"
|
||||||
#include "wpa_supplicant_i.h"
|
#include "wpa_supplicant_i.h"
|
||||||
|
#include "notify.h"
|
||||||
#include "driver_i.h"
|
#include "driver_i.h"
|
||||||
#include "wpa.h"
|
#include "wpa.h"
|
||||||
#include "ieee802_11_defs.h"
|
#include "ieee802_11_defs.h"
|
||||||
|
@ -2245,7 +2246,7 @@ static int ieee80211_ibss_allowed(struct wpa_supplicant *wpa_s)
|
||||||
static int ieee80211_sta_join_ibss(struct wpa_supplicant *wpa_s,
|
static int ieee80211_sta_join_ibss(struct wpa_supplicant *wpa_s,
|
||||||
struct ieee80211_sta_bss *bss)
|
struct ieee80211_sta_bss *bss)
|
||||||
{
|
{
|
||||||
int res = 0, rates, done = 0;
|
int res = 0, rates, done = 0, bssid_changed;
|
||||||
struct ieee80211_mgmt *mgmt;
|
struct ieee80211_mgmt *mgmt;
|
||||||
#if 0 /* FIX */
|
#if 0 /* FIX */
|
||||||
struct ieee80211_tx_control control;
|
struct ieee80211_tx_control control;
|
||||||
|
@ -2264,7 +2265,10 @@ static int ieee80211_sta_join_ibss(struct wpa_supplicant *wpa_s,
|
||||||
local->hw->reset_tsf(local->mdev);
|
local->hw->reset_tsf(local->mdev);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
bssid_changed = os_memcmp(wpa_s->bssid, bss->bssid, ETH_ALEN);
|
||||||
os_memcpy(wpa_s->bssid, bss->bssid, ETH_ALEN);
|
os_memcpy(wpa_s->bssid, bss->bssid, ETH_ALEN);
|
||||||
|
if (bssid_changed)
|
||||||
|
wpas_notify_bssid_changed(wpa_s);
|
||||||
|
|
||||||
#if 0 /* FIX */
|
#if 0 /* FIX */
|
||||||
local->conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10;
|
local->conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10;
|
||||||
|
@ -2580,11 +2584,17 @@ int ieee80211_sta_associate(struct wpa_supplicant *wpa_s,
|
||||||
struct wpa_driver_associate_params *params)
|
struct wpa_driver_associate_params *params)
|
||||||
{
|
{
|
||||||
struct ieee80211_sta_bss *bss;
|
struct ieee80211_sta_bss *bss;
|
||||||
|
int bssid_changed;
|
||||||
|
|
||||||
wpa_s->mlme.bssid_set = 0;
|
wpa_s->mlme.bssid_set = 0;
|
||||||
wpa_s->mlme.freq = params->freq;
|
wpa_s->mlme.freq = params->freq;
|
||||||
if (params->bssid) {
|
if (params->bssid) {
|
||||||
|
bssid_changed = os_memcmp(wpa_s->bssid, params->bssid,
|
||||||
|
ETH_ALEN);
|
||||||
os_memcpy(wpa_s->bssid, params->bssid, ETH_ALEN);
|
os_memcpy(wpa_s->bssid, params->bssid, ETH_ALEN);
|
||||||
|
if (bssid_changed)
|
||||||
|
wpas_notify_bssid_changed(wpa_s);
|
||||||
|
|
||||||
if (!is_zero_ether_addr(params->bssid))
|
if (!is_zero_ether_addr(params->bssid))
|
||||||
wpa_s->mlme.bssid_set = 1;
|
wpa_s->mlme.bssid_set = 1;
|
||||||
bss = ieee80211_bss_get(wpa_s, wpa_s->bssid);
|
bss = ieee80211_bss_get(wpa_s, wpa_s->bssid);
|
||||||
|
|
138
wpa_supplicant/notify.c
Normal file
138
wpa_supplicant/notify.c
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
/*
|
||||||
|
* wpa_supplicant - Event notifications
|
||||||
|
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* Alternatively, this software may be distributed under the terms of BSD
|
||||||
|
* license.
|
||||||
|
*
|
||||||
|
* See README and COPYING for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "includes.h"
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "wpa_supplicant_i.h"
|
||||||
|
#include "wps_supplicant.h"
|
||||||
|
#include "ctrl_iface_dbus.h"
|
||||||
|
#include "notify.h"
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
|
||||||
|
wpa_states new_state, wpa_states old_state)
|
||||||
|
{
|
||||||
|
/* notify the old DBus API */
|
||||||
|
wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
|
||||||
|
old_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wpa_ssid *ssid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wpa_ssid *ssid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_unregister_interface(struct wpa_supplicant *wpa_s)
|
||||||
|
{
|
||||||
|
/* unregister interface in old DBus ctrl iface */
|
||||||
|
wpas_dbus_unregister_iface(wpa_s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
|
||||||
|
{
|
||||||
|
/* notify the old DBus API */
|
||||||
|
wpa_supplicant_dbus_notify_scanning(wpa_s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
|
||||||
|
{
|
||||||
|
/* notify the old DBus API */
|
||||||
|
wpa_supplicant_dbus_notify_scan_results(wpa_s);
|
||||||
|
|
||||||
|
wpas_wps_notify_scan_results(wpa_s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
|
||||||
|
const struct wps_credential *cred)
|
||||||
|
{
|
||||||
|
/* notify the old DBus API */
|
||||||
|
wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wps_event_m2d *m2d)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wps_event_fail *fail)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wpa_ssid *ssid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wpa_ssid *ssid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_debug_params_changed(struct wpa_global *global)
|
||||||
|
{
|
||||||
|
}
|
51
wpa_supplicant/notify.h
Normal file
51
wpa_supplicant/notify.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* wpa_supplicant - Event notifications
|
||||||
|
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* Alternatively, this software may be distributed under the terms of BSD
|
||||||
|
* license.
|
||||||
|
*
|
||||||
|
* See README and COPYING for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOTIFY_H
|
||||||
|
#define NOTIFY_H
|
||||||
|
|
||||||
|
struct wps_credential;
|
||||||
|
struct wps_event_m2d;
|
||||||
|
struct wps_event_fail;
|
||||||
|
|
||||||
|
void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
|
||||||
|
wpa_states new_state, wpa_states old_state);
|
||||||
|
void wpas_notify_network_changed(struct wpa_supplicant *wpa_s);
|
||||||
|
void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s);
|
||||||
|
void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s);
|
||||||
|
void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wpa_ssid *ssid);
|
||||||
|
void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wpa_ssid *ssid);
|
||||||
|
void wpas_notify_unregister_interface(struct wpa_supplicant *wpa_s);
|
||||||
|
void wpas_notify_scanning(struct wpa_supplicant *wpa_s);
|
||||||
|
void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success);
|
||||||
|
void wpas_notify_scan_results(struct wpa_supplicant *wpa_s);
|
||||||
|
void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
|
||||||
|
const struct wps_credential *cred);
|
||||||
|
void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wps_event_m2d *m2d);
|
||||||
|
void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wps_event_fail *fail);
|
||||||
|
void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s);
|
||||||
|
void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wpa_ssid *ssid);
|
||||||
|
void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
|
||||||
|
struct wpa_ssid *ssid);
|
||||||
|
void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name);
|
||||||
|
void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name);
|
||||||
|
|
||||||
|
void wpas_notify_debug_params_changed(struct wpa_global *global);
|
||||||
|
|
||||||
|
#endif /* NOTIFY_H */
|
|
@ -21,7 +21,7 @@
|
||||||
#include "driver_i.h"
|
#include "driver_i.h"
|
||||||
#include "mlme.h"
|
#include "mlme.h"
|
||||||
#include "wps_supplicant.h"
|
#include "wps_supplicant.h"
|
||||||
#include "ctrl_iface_dbus.h"
|
#include "notify.h"
|
||||||
|
|
||||||
|
|
||||||
static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
|
static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
|
||||||
|
@ -33,8 +33,11 @@ static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
|
||||||
if (ssid == NULL)
|
if (ssid == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (wpa_s->current_ssid == NULL)
|
if (wpa_s->current_ssid == NULL) {
|
||||||
wpa_s->current_ssid = ssid;
|
wpa_s->current_ssid = ssid;
|
||||||
|
if (wpa_s->current_ssid != NULL)
|
||||||
|
wpas_notify_network_changed(wpa_s);
|
||||||
|
}
|
||||||
wpa_supplicant_initiate_eapol(wpa_s);
|
wpa_supplicant_initiate_eapol(wpa_s);
|
||||||
wpa_printf(MSG_DEBUG, "Already associated with a configured network - "
|
wpa_printf(MSG_DEBUG, "Already associated with a configured network - "
|
||||||
"generating associated event");
|
"generating associated event");
|
||||||
|
@ -203,6 +206,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
|
||||||
wpa_printf(MSG_DEBUG, "Using wired authentication - "
|
wpa_printf(MSG_DEBUG, "Using wired authentication - "
|
||||||
"overriding ap_scan configuration");
|
"overriding ap_scan configuration");
|
||||||
wpa_s->conf->ap_scan = 0;
|
wpa_s->conf->ap_scan = 0;
|
||||||
|
wpas_notify_ap_scan_changed(wpa_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wpa_s->conf->ap_scan == 0) {
|
if (wpa_s->conf->ap_scan == 0) {
|
||||||
|
@ -348,6 +352,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
wpa_printf(MSG_WARNING, "Failed to initiate AP scan.");
|
wpa_printf(MSG_WARNING, "Failed to initiate AP scan.");
|
||||||
wpa_supplicant_notify_scanning(wpa_s, 0);
|
wpa_supplicant_notify_scanning(wpa_s, 0);
|
||||||
|
wpas_notify_scan_done(wpa_s, 0);
|
||||||
wpa_supplicant_req_scan(wpa_s, 10, 0);
|
wpa_supplicant_req_scan(wpa_s, 10, 0);
|
||||||
} else
|
} else
|
||||||
wpa_s->scan_runs++;
|
wpa_s->scan_runs++;
|
||||||
|
@ -413,7 +418,7 @@ void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,
|
||||||
{
|
{
|
||||||
if (wpa_s->scanning != scanning) {
|
if (wpa_s->scanning != scanning) {
|
||||||
wpa_s->scanning = scanning;
|
wpa_s->scanning = scanning;
|
||||||
wpa_supplicant_dbus_notify_scanning(wpa_s);
|
wpas_notify_scanning(wpa_s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,17 +25,19 @@
|
||||||
#include "driver_i.h"
|
#include "driver_i.h"
|
||||||
#include "wpas_glue.h"
|
#include "wpas_glue.h"
|
||||||
#include "wps_supplicant.h"
|
#include "wps_supplicant.h"
|
||||||
|
#include "notify.h"
|
||||||
#include "sme.h"
|
#include "sme.h"
|
||||||
|
|
||||||
void sme_authenticate(struct wpa_supplicant *wpa_s,
|
void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||||
struct wpa_scan_res *bss, struct wpa_ssid *ssid)
|
struct wpa_scan_res *bss, struct wpa_ssid *ssid)
|
||||||
{
|
{
|
||||||
struct wpa_driver_auth_params params;
|
struct wpa_driver_auth_params params;
|
||||||
|
struct wpa_ssid *old_ssid;
|
||||||
const u8 *ie;
|
const u8 *ie;
|
||||||
#ifdef CONFIG_IEEE80211R
|
#ifdef CONFIG_IEEE80211R
|
||||||
const u8 *md = NULL;
|
const u8 *md = NULL;
|
||||||
#endif /* CONFIG_IEEE80211R */
|
#endif /* CONFIG_IEEE80211R */
|
||||||
int i;
|
int i, bssid_changed;
|
||||||
|
|
||||||
if (bss == NULL) {
|
if (bss == NULL) {
|
||||||
wpa_printf(MSG_ERROR, "SME: No scan result available for the "
|
wpa_printf(MSG_ERROR, "SME: No scan result available for the "
|
||||||
|
@ -92,8 +94,11 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||||
}
|
}
|
||||||
params.wep_tx_keyidx = ssid->wep_tx_keyidx;
|
params.wep_tx_keyidx = ssid->wep_tx_keyidx;
|
||||||
|
|
||||||
|
bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
|
||||||
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
||||||
os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
|
os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
|
||||||
|
if (bssid_changed)
|
||||||
|
wpas_notify_bssid_changed(wpa_s);
|
||||||
|
|
||||||
if (bss && (wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
|
if (bss && (wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
|
||||||
wpa_scan_get_ie(bss, WLAN_EID_RSN)) &&
|
wpa_scan_get_ie(bss, WLAN_EID_RSN)) &&
|
||||||
|
@ -220,9 +225,12 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
|
||||||
|
|
||||||
wpa_clear_keys(wpa_s, bss->bssid);
|
wpa_clear_keys(wpa_s, bss->bssid);
|
||||||
wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
|
wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
|
||||||
|
old_ssid = wpa_s->current_ssid;
|
||||||
wpa_s->current_ssid = ssid;
|
wpa_s->current_ssid = ssid;
|
||||||
wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
|
wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
|
||||||
wpa_supplicant_initiate_eapol(wpa_s);
|
wpa_supplicant_initiate_eapol(wpa_s);
|
||||||
|
if (old_ssid != wpa_s->current_ssid)
|
||||||
|
wpas_notify_network_changed(wpa_s);
|
||||||
|
|
||||||
if (wpa_drv_authenticate(wpa_s, ¶ms) < 0) {
|
if (wpa_drv_authenticate(wpa_s, ¶ms) < 0) {
|
||||||
wpa_msg(wpa_s, MSG_INFO, "Authentication request to the "
|
wpa_msg(wpa_s, MSG_INFO, "Authentication request to the "
|
||||||
|
@ -348,12 +356,17 @@ int sme_update_ft_ies(struct wpa_supplicant *wpa_s, const u8 *md,
|
||||||
void sme_event_assoc_reject(struct wpa_supplicant *wpa_s,
|
void sme_event_assoc_reject(struct wpa_supplicant *wpa_s,
|
||||||
union wpa_event_data *data)
|
union wpa_event_data *data)
|
||||||
{
|
{
|
||||||
|
int bssid_changed;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "SME: Association failed: status code %d",
|
wpa_printf(MSG_DEBUG, "SME: Association failed: status code %d",
|
||||||
data->assoc_reject.status_code);
|
data->assoc_reject.status_code);
|
||||||
|
|
||||||
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
|
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
|
||||||
|
bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
|
||||||
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
||||||
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
|
os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
|
||||||
|
if (bssid_changed)
|
||||||
|
wpas_notify_bssid_changed(wpa_s);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: if more than one possible AP is available in scan results,
|
* TODO: if more than one possible AP is available in scan results,
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "ibss_rsn.h"
|
#include "ibss_rsn.h"
|
||||||
#include "sme.h"
|
#include "sme.h"
|
||||||
#include "ap.h"
|
#include "ap.h"
|
||||||
|
#include "notify.h"
|
||||||
|
|
||||||
const char *wpa_supplicant_version =
|
const char *wpa_supplicant_version =
|
||||||
"wpa_supplicant v" VERSION_STR "\n"
|
"wpa_supplicant v" VERSION_STR "\n"
|
||||||
|
@ -517,8 +518,7 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state)
|
||||||
if (state != WPA_SCANNING)
|
if (state != WPA_SCANNING)
|
||||||
wpa_supplicant_notify_scanning(wpa_s, 0);
|
wpa_supplicant_notify_scanning(wpa_s, 0);
|
||||||
|
|
||||||
wpa_supplicant_dbus_notify_state_change(wpa_s, state,
|
wpas_notify_state_changed(wpa_s, state, wpa_s->wpa_state);
|
||||||
wpa_s->wpa_state);
|
|
||||||
|
|
||||||
if (state == WPA_COMPLETED && wpa_s->new_connection) {
|
if (state == WPA_COMPLETED && wpa_s->new_connection) {
|
||||||
#if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
|
#if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
|
||||||
|
@ -557,11 +557,13 @@ static void wpa_supplicant_terminate(int sig, void *eloop_ctx,
|
||||||
|
|
||||||
static void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
|
static void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
|
wpa_states old_state = wpa_s->wpa_state;
|
||||||
wpa_s->pairwise_cipher = 0;
|
wpa_s->pairwise_cipher = 0;
|
||||||
wpa_s->group_cipher = 0;
|
wpa_s->group_cipher = 0;
|
||||||
wpa_s->mgmt_group_cipher = 0;
|
wpa_s->mgmt_group_cipher = 0;
|
||||||
wpa_s->key_mgmt = 0;
|
wpa_s->key_mgmt = 0;
|
||||||
wpa_s->wpa_state = WPA_DISCONNECTED;
|
wpa_s->wpa_state = WPA_DISCONNECTED;
|
||||||
|
wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -579,7 +581,10 @@ static void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
|
||||||
int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
|
int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
struct wpa_config *conf;
|
struct wpa_config *conf;
|
||||||
|
struct wpa_ssid *old_ssid;
|
||||||
int reconf_ctrl;
|
int reconf_ctrl;
|
||||||
|
int old_ap_scan;
|
||||||
|
|
||||||
if (wpa_s->confname == NULL)
|
if (wpa_s->confname == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
conf = wpa_config_read(wpa_s->confname);
|
conf = wpa_config_read(wpa_s->confname);
|
||||||
|
@ -600,7 +605,11 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
|
||||||
}
|
}
|
||||||
|
|
||||||
eapol_sm_invalidate_cached_session(wpa_s->eapol);
|
eapol_sm_invalidate_cached_session(wpa_s->eapol);
|
||||||
|
old_ssid = wpa_s->current_ssid;
|
||||||
wpa_s->current_ssid = NULL;
|
wpa_s->current_ssid = NULL;
|
||||||
|
if (old_ssid != wpa_s->current_ssid)
|
||||||
|
wpas_notify_network_changed(wpa_s);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: should notify EAPOL SM about changes in opensc_engine_path,
|
* TODO: should notify EAPOL SM about changes in opensc_engine_path,
|
||||||
* pkcs11_engine_path, pkcs11_module_path.
|
* pkcs11_engine_path, pkcs11_module_path.
|
||||||
|
@ -616,8 +625,13 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
|
||||||
wpa_sm_set_config(wpa_s->wpa, NULL);
|
wpa_sm_set_config(wpa_s->wpa, NULL);
|
||||||
wpa_sm_set_fast_reauth(wpa_s->wpa, wpa_s->conf->fast_reauth);
|
wpa_sm_set_fast_reauth(wpa_s->wpa, wpa_s->conf->fast_reauth);
|
||||||
rsn_preauth_deinit(wpa_s->wpa);
|
rsn_preauth_deinit(wpa_s->wpa);
|
||||||
|
|
||||||
|
old_ap_scan = wpa_s->conf->ap_scan;
|
||||||
wpa_config_free(wpa_s->conf);
|
wpa_config_free(wpa_s->conf);
|
||||||
wpa_s->conf = conf;
|
wpa_s->conf = conf;
|
||||||
|
if (old_ap_scan != wpa_s->conf->ap_scan)
|
||||||
|
wpas_notify_ap_scan_changed(wpa_s);
|
||||||
|
|
||||||
if (reconf_ctrl)
|
if (reconf_ctrl)
|
||||||
wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
|
wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
|
||||||
|
|
||||||
|
@ -945,13 +959,14 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||||
{
|
{
|
||||||
u8 wpa_ie[80];
|
u8 wpa_ie[80];
|
||||||
size_t wpa_ie_len;
|
size_t wpa_ie_len;
|
||||||
int use_crypt, ret, i;
|
int use_crypt, ret, i, bssid_changed;
|
||||||
int algs = AUTH_ALG_OPEN_SYSTEM;
|
int algs = AUTH_ALG_OPEN_SYSTEM;
|
||||||
wpa_cipher cipher_pairwise, cipher_group;
|
wpa_cipher cipher_pairwise, cipher_group;
|
||||||
struct wpa_driver_associate_params params;
|
struct wpa_driver_associate_params params;
|
||||||
int wep_keys_set = 0;
|
int wep_keys_set = 0;
|
||||||
struct wpa_driver_capa capa;
|
struct wpa_driver_capa capa;
|
||||||
int assoc_failed = 0;
|
int assoc_failed = 0;
|
||||||
|
struct wpa_ssid *old_ssid;
|
||||||
|
|
||||||
if (ssid->mode == 2) {
|
if (ssid->mode == 2) {
|
||||||
#ifdef CONFIG_AP
|
#ifdef CONFIG_AP
|
||||||
|
@ -982,8 +997,11 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||||
wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
|
wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
|
||||||
" (SSID='%s' freq=%d MHz)", MAC2STR(bss->bssid),
|
" (SSID='%s' freq=%d MHz)", MAC2STR(bss->bssid),
|
||||||
ie ? wpa_ssid_txt(ie + 2, ie[1]) : "", bss->freq);
|
ie ? wpa_ssid_txt(ie + 2, ie[1]) : "", bss->freq);
|
||||||
|
bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
|
||||||
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
os_memset(wpa_s->bssid, 0, ETH_ALEN);
|
||||||
os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
|
os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
|
||||||
|
if (bssid_changed)
|
||||||
|
wpas_notify_bssid_changed(wpa_s);
|
||||||
#ifdef CONFIG_IEEE80211R
|
#ifdef CONFIG_IEEE80211R
|
||||||
ie = wpa_scan_get_ie(bss, WLAN_EID_MOBILITY_DOMAIN);
|
ie = wpa_scan_get_ie(bss, WLAN_EID_MOBILITY_DOMAIN);
|
||||||
if (ie && ie[1] >= MOBILITY_DOMAIN_ID_LEN)
|
if (ie && ie[1] >= MOBILITY_DOMAIN_ID_LEN)
|
||||||
|
@ -1257,9 +1275,12 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||||
*/
|
*/
|
||||||
eapol_sm_invalidate_cached_session(wpa_s->eapol);
|
eapol_sm_invalidate_cached_session(wpa_s->eapol);
|
||||||
}
|
}
|
||||||
|
old_ssid = wpa_s->current_ssid;
|
||||||
wpa_s->current_ssid = ssid;
|
wpa_s->current_ssid = ssid;
|
||||||
wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
|
wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
|
||||||
wpa_supplicant_initiate_eapol(wpa_s);
|
wpa_supplicant_initiate_eapol(wpa_s);
|
||||||
|
if (old_ssid != wpa_s->current_ssid)
|
||||||
|
wpas_notify_network_changed(wpa_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1274,7 +1295,9 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
|
||||||
void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
|
void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
|
||||||
int reason_code)
|
int reason_code)
|
||||||
{
|
{
|
||||||
|
struct wpa_ssid *old_ssid;
|
||||||
u8 *addr = NULL;
|
u8 *addr = NULL;
|
||||||
|
|
||||||
if (!is_zero_ether_addr(wpa_s->bssid)) {
|
if (!is_zero_ether_addr(wpa_s->bssid)) {
|
||||||
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
|
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
|
||||||
ieee80211_sta_disassociate(wpa_s, reason_code);
|
ieee80211_sta_disassociate(wpa_s, reason_code);
|
||||||
|
@ -1284,9 +1307,12 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
|
||||||
}
|
}
|
||||||
wpa_clear_keys(wpa_s, addr);
|
wpa_clear_keys(wpa_s, addr);
|
||||||
wpa_supplicant_mark_disassoc(wpa_s);
|
wpa_supplicant_mark_disassoc(wpa_s);
|
||||||
|
old_ssid = wpa_s->current_ssid;
|
||||||
wpa_s->current_ssid = NULL;
|
wpa_s->current_ssid = NULL;
|
||||||
wpa_sm_set_config(wpa_s->wpa, NULL);
|
wpa_sm_set_config(wpa_s->wpa, NULL);
|
||||||
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
|
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
|
||||||
|
if (old_ssid != wpa_s->current_ssid)
|
||||||
|
wpas_notify_network_changed(wpa_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1301,7 +1327,9 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
|
||||||
void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
|
void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
|
||||||
int reason_code)
|
int reason_code)
|
||||||
{
|
{
|
||||||
|
struct wpa_ssid *old_ssid;
|
||||||
u8 *addr = NULL;
|
u8 *addr = NULL;
|
||||||
|
|
||||||
if (!is_zero_ether_addr(wpa_s->bssid)) {
|
if (!is_zero_ether_addr(wpa_s->bssid)) {
|
||||||
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
|
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
|
||||||
ieee80211_sta_deauthenticate(wpa_s, reason_code);
|
ieee80211_sta_deauthenticate(wpa_s, reason_code);
|
||||||
|
@ -1312,9 +1340,12 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
|
||||||
}
|
}
|
||||||
wpa_clear_keys(wpa_s, addr);
|
wpa_clear_keys(wpa_s, addr);
|
||||||
wpa_supplicant_mark_disassoc(wpa_s);
|
wpa_supplicant_mark_disassoc(wpa_s);
|
||||||
|
old_ssid = wpa_s->current_ssid;
|
||||||
wpa_s->current_ssid = NULL;
|
wpa_s->current_ssid = NULL;
|
||||||
wpa_sm_set_config(wpa_s->wpa, NULL);
|
wpa_sm_set_config(wpa_s->wpa, NULL);
|
||||||
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
|
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
|
||||||
|
if (old_ssid != wpa_s->current_ssid)
|
||||||
|
wpas_notify_network_changed(wpa_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2001,7 +2032,7 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s)
|
||||||
wpa_clear_keys(wpa_s, NULL);
|
wpa_clear_keys(wpa_s, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
wpas_dbus_unregister_iface(wpa_s);
|
wpas_notify_unregister_interface(wpa_s);
|
||||||
|
|
||||||
wpa_supplicant_cleanup(wpa_s);
|
wpa_supplicant_cleanup(wpa_s);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "eloop.h"
|
#include "eloop.h"
|
||||||
#include "uuid.h"
|
#include "uuid.h"
|
||||||
#include "wpa_ctrl.h"
|
#include "wpa_ctrl.h"
|
||||||
#include "ctrl_iface_dbus.h"
|
#include "notify.h"
|
||||||
#include "eap_common/eap_wsc_common.h"
|
#include "eap_common/eap_wsc_common.h"
|
||||||
#include "blacklist.h"
|
#include "blacklist.h"
|
||||||
#include "wpa.h"
|
#include "wpa.h"
|
||||||
|
@ -202,7 +202,8 @@ static int wpa_supplicant_wps_cred(void *ctx,
|
||||||
WPS_EVENT_CRED_RECEIVED, buf);
|
WPS_EVENT_CRED_RECEIVED, buf);
|
||||||
os_free(buf);
|
os_free(buf);
|
||||||
}
|
}
|
||||||
wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
|
|
||||||
|
wpas_notify_wps_credential(wpa_s, cred);
|
||||||
} else
|
} else
|
||||||
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_CRED_RECEIVED);
|
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_CRED_RECEIVED);
|
||||||
|
|
||||||
|
@ -255,6 +256,7 @@ static int wpa_supplicant_wps_cred(void *ctx,
|
||||||
ssid = wpa_config_add_network(wpa_s->conf);
|
ssid = wpa_config_add_network(wpa_s->conf);
|
||||||
if (ssid == NULL)
|
if (ssid == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
wpas_notify_network_added(wpa_s, ssid);
|
||||||
}
|
}
|
||||||
|
|
||||||
wpa_config_set_network_defaults(ssid);
|
wpa_config_set_network_defaults(ssid);
|
||||||
|
@ -387,6 +389,7 @@ static void wpa_supplicant_wps_event_m2d(struct wpa_supplicant *wpa_s,
|
||||||
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_M2D
|
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_M2D
|
||||||
"dev_password_id=%d config_error=%d",
|
"dev_password_id=%d config_error=%d",
|
||||||
m2d->dev_password_id, m2d->config_error);
|
m2d->dev_password_id, m2d->config_error);
|
||||||
|
wpas_notify_wps_event_m2d(wpa_s, m2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -395,6 +398,7 @@ static void wpa_supplicant_wps_event_fail(struct wpa_supplicant *wpa_s,
|
||||||
{
|
{
|
||||||
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_FAIL "msg=%d", fail->msg);
|
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_FAIL "msg=%d", fail->msg);
|
||||||
wpas_clear_wps(wpa_s);
|
wpas_clear_wps(wpa_s);
|
||||||
|
wpas_notify_wps_event_fail(wpa_s, fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -402,6 +406,7 @@ static void wpa_supplicant_wps_event_success(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_SUCCESS);
|
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_SUCCESS);
|
||||||
wpa_s->wps_success = 1;
|
wpa_s->wps_success = 1;
|
||||||
|
wpas_notify_wps_event_success(wpa_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -438,7 +443,7 @@ enum wps_request_type wpas_wps_get_req_type(struct wpa_ssid *ssid)
|
||||||
static void wpas_clear_wps(struct wpa_supplicant *wpa_s)
|
static void wpas_clear_wps(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
struct wpa_ssid *ssid;
|
struct wpa_ssid *ssid, *remove_ssid = NULL;
|
||||||
|
|
||||||
eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
|
eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
|
||||||
|
|
||||||
|
@ -446,16 +451,22 @@ static void wpas_clear_wps(struct wpa_supplicant *wpa_s)
|
||||||
ssid = wpa_s->conf->ssid;
|
ssid = wpa_s->conf->ssid;
|
||||||
while (ssid) {
|
while (ssid) {
|
||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
|
||||||
if (ssid == wpa_s->current_ssid)
|
if (ssid == wpa_s->current_ssid) {
|
||||||
wpa_s->current_ssid = NULL;
|
wpa_s->current_ssid = NULL;
|
||||||
|
if (ssid != NULL)
|
||||||
|
wpas_notify_network_changed(wpa_s);
|
||||||
|
}
|
||||||
id = ssid->id;
|
id = ssid->id;
|
||||||
|
remove_ssid = ssid;
|
||||||
} else
|
} else
|
||||||
id = -1;
|
id = -1;
|
||||||
ssid = ssid->next;
|
ssid = ssid->next;
|
||||||
if (id >= 0)
|
if (id >= 0) {
|
||||||
|
wpas_notify_network_removed(wpa_s, remove_ssid);
|
||||||
wpa_config_remove_network(wpa_s->conf, id);
|
wpa_config_remove_network(wpa_s->conf, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx)
|
static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx)
|
||||||
|
@ -475,12 +486,14 @@ static struct wpa_ssid * wpas_wps_add_network(struct wpa_supplicant *wpa_s,
|
||||||
ssid = wpa_config_add_network(wpa_s->conf);
|
ssid = wpa_config_add_network(wpa_s->conf);
|
||||||
if (ssid == NULL)
|
if (ssid == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
wpas_notify_network_added(wpa_s, ssid);
|
||||||
wpa_config_set_network_defaults(ssid);
|
wpa_config_set_network_defaults(ssid);
|
||||||
if (wpa_config_set(ssid, "key_mgmt", "WPS", 0) < 0 ||
|
if (wpa_config_set(ssid, "key_mgmt", "WPS", 0) < 0 ||
|
||||||
wpa_config_set(ssid, "eap", "WSC", 0) < 0 ||
|
wpa_config_set(ssid, "eap", "WSC", 0) < 0 ||
|
||||||
wpa_config_set(ssid, "identity", registrar ?
|
wpa_config_set(ssid, "identity", registrar ?
|
||||||
"\"" WSC_ID_REGISTRAR "\"" :
|
"\"" WSC_ID_REGISTRAR "\"" :
|
||||||
"\"" WSC_ID_ENROLLEE "\"", 0) < 0) {
|
"\"" WSC_ID_ENROLLEE "\"", 0) < 0) {
|
||||||
|
wpas_notify_network_removed(wpa_s, ssid);
|
||||||
wpa_config_remove_network(wpa_s->conf, ssid->id);
|
wpa_config_remove_network(wpa_s->conf, ssid->id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -529,7 +542,10 @@ static void wpas_wps_reassoc(struct wpa_supplicant *wpa_s,
|
||||||
/* Mark all other networks disabled and trigger reassociation */
|
/* Mark all other networks disabled and trigger reassociation */
|
||||||
ssid = wpa_s->conf->ssid;
|
ssid = wpa_s->conf->ssid;
|
||||||
while (ssid) {
|
while (ssid) {
|
||||||
|
int was_disabled = ssid->disabled;
|
||||||
ssid->disabled = ssid != selected;
|
ssid->disabled = ssid != selected;
|
||||||
|
if (was_disabled != ssid->disabled)
|
||||||
|
wpas_notify_network_enabled_changed(wpa_s, ssid);
|
||||||
ssid = ssid->next;
|
ssid = ssid->next;
|
||||||
}
|
}
|
||||||
wpa_s->disconnected = 0;
|
wpa_s->disconnected = 0;
|
||||||
|
|
Loading…
Reference in a new issue