notify.c
Go to the documentation of this file.
00001 /*
00002  * wpa_supplicant - Event notifications
00003  * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation.
00008  *
00009  * Alternatively, this software may be distributed under the terms of BSD
00010  * license.
00011  *
00012  * See README and COPYING for more details.
00013  */
00014 
00015 #include "utils/includes.h"
00016 
00017 #include "utils/common.h"
00018 #include "common/wpa_ctrl.h"
00019 #include "config.h"
00020 #include "wpa_supplicant_i.h"
00021 #include "wps_supplicant.h"
00022 #include "dbus/dbus_common.h"
00023 #include "dbus/dbus_old.h"
00024 #include "dbus/dbus_new.h"
00025 #include "driver_i.h"
00026 #include "scan.h"
00027 #include "notify.h"
00028 
00029 #include "../../src/nodes/wpa_supplicant_node.h"
00030 
00031 int wpas_notify_supplicant_initialized(struct wpa_global *global)
00032 {
00033 #ifdef CONFIG_DBUS
00034         if (global->params.dbus_ctrl_interface) {
00035                 global->dbus = wpas_dbus_init(global);
00036                 if (global->dbus == NULL)
00037                         return -1;
00038         }
00039 #endif /* CONFIG_DBUS */
00040 
00041         return 0;
00042 }
00043 
00044 
00045 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
00046 {
00047 #ifdef CONFIG_DBUS
00048         if (global->dbus)
00049                 wpas_dbus_deinit(global->dbus);
00050 #endif /* CONFIG_DBUS */
00051 }
00052 
00053 
00054 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
00055 {
00056         if (wpas_dbus_register_iface(wpa_s))
00057                 return -1;
00058 
00059         if (wpas_dbus_register_interface(wpa_s))
00060                 return -1;
00061 
00062         return 0;
00063 }
00064 
00065 
00066 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
00067 {
00068         /* unregister interface in old DBus ctrl iface */
00069         wpas_dbus_unregister_iface(wpa_s);
00070 
00071         /* unregister interface in new DBus ctrl iface */
00072         wpas_dbus_unregister_interface(wpa_s);
00073 }
00074 
00075 
00076 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
00077                                enum wpa_states new_state,
00078                                enum wpa_states old_state)
00079 {
00080         /* notify the old DBus API */
00081         wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
00082                                                 old_state);
00083 
00084         /* notify the new DBus API */
00085         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
00086 }
00087 
00088 
00089 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
00090 {
00091         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
00092 }
00093 
00094 
00095 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
00096 {
00097         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
00098 }
00099 
00100 
00101 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
00102 {
00103         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
00104 }
00105 
00106 
00107 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
00108                                          struct wpa_ssid *ssid)
00109 {
00110         wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
00111         ros_network_list_updated(wpa_s);
00112 }
00113 
00114 
00115 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
00116                                   struct wpa_ssid *ssid)
00117 {
00118         wpas_dbus_signal_network_selected(wpa_s, ssid->id);
00119 }
00120 
00121 
00122 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
00123 {
00124         /* notify the old DBus API */
00125         wpa_supplicant_dbus_notify_scanning(wpa_s);
00126 
00127         /* notify the new DBus API */
00128         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
00129 }
00130 
00131 
00132 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
00133 {
00134         wpas_dbus_signal_scan_done(wpa_s, success);
00135 }
00136 
00137 
00138 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
00139 {
00140         /* notify the old DBus API */
00141         wpa_supplicant_dbus_notify_scan_results(wpa_s);
00142 
00143         wpas_wps_notify_scan_results(wpa_s);
00144 }
00145 
00146 
00147 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
00148                                 const struct wps_credential *cred)
00149 {
00150 #ifdef CONFIG_WPS
00151         /* notify the old DBus API */
00152         wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
00153         /* notify the new DBus API */
00154         wpas_dbus_signal_wps_cred(wpa_s, cred);
00155 #endif /* CONFIG_WPS */
00156 }
00157 
00158 
00159 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
00160                                struct wps_event_m2d *m2d)
00161 {
00162 #ifdef CONFIG_WPS
00163         wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
00164 #endif /* CONFIG_WPS */
00165 }
00166 
00167 
00168 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
00169                                 struct wps_event_fail *fail)
00170 {
00171 #ifdef CONFIG_WPS
00172         wpas_dbus_signal_wps_event_fail(wpa_s, fail);
00173 #endif /* CONFIG_WPS */
00174 }
00175 
00176 
00177 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
00178 {
00179 #ifdef CONFIG_WPS
00180         wpas_dbus_signal_wps_event_success(wpa_s);
00181 #endif /* CONFIG_WPS */
00182 }
00183 
00184 
00185 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
00186                                struct wpa_ssid *ssid)
00187 {
00188         wpas_dbus_register_network(wpa_s, ssid);
00189         ros_network_list_updated(wpa_s);
00190 }
00191 
00192 
00193 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
00194                                  struct wpa_ssid *ssid)
00195 {
00196         wpas_dbus_unregister_network(wpa_s, ssid->id);
00197         ros_network_list_updated(wpa_s);
00198 }
00199 
00200 
00201 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
00202                            u8 bssid[], unsigned int id)
00203 {
00204         wpas_dbus_register_bss(wpa_s, bssid, id);
00205         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
00206                      id, MAC2STR(bssid));
00207 }
00208 
00209 
00210 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
00211                              u8 bssid[], unsigned int id)
00212 {
00213         wpas_dbus_unregister_bss(wpa_s, bssid, id);
00214         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
00215                      id, MAC2STR(bssid));
00216 }
00217 
00218 
00219 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
00220                                   unsigned int id)
00221 {
00222         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
00223 }
00224 
00225 
00226 void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
00227                                     unsigned int id)
00228 {
00229         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
00230                                           id);
00231 }
00232 
00233 
00234 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
00235                                      unsigned int id)
00236 {
00237         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
00238                                           id);
00239 }
00240 
00241 
00242 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
00243                                   unsigned int id)
00244 {
00245         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
00246 }
00247 
00248 
00249 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
00250                                    unsigned int id)
00251 {
00252         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
00253 }
00254 
00255 
00256 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
00257                                    unsigned int id)
00258 {
00259         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
00260 }
00261 
00262 
00263 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
00264                                  unsigned int id)
00265 {
00266 }
00267 
00268 
00269 void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
00270                                    unsigned int id)
00271 {
00272         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
00273 }
00274 
00275 
00276 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
00277                                    unsigned int id)
00278 {
00279         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
00280 }
00281 
00282 
00283 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
00284 {
00285         wpas_dbus_signal_blob_added(wpa_s, name);
00286 }
00287 
00288 
00289 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
00290 {
00291         wpas_dbus_signal_blob_removed(wpa_s, name);
00292 }
00293 
00294 
00295 void wpas_notify_debug_level_changed(struct wpa_global *global)
00296 {
00297         wpas_dbus_signal_debug_level_changed(global);
00298 }
00299 
00300 
00301 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
00302 {
00303         wpas_dbus_signal_debug_timestamp_changed(global);
00304 }
00305 
00306 
00307 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
00308 {
00309         wpas_dbus_signal_debug_show_keys_changed(global);
00310 }
00311 
00312 
00313 void wpas_notify_suspend(struct wpa_global *global)
00314 {
00315         struct wpa_supplicant *wpa_s;
00316 
00317         os_get_time(&global->suspend_time);
00318         wpa_printf(MSG_DEBUG, "System suspend notification");
00319         for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
00320                 wpa_drv_suspend(wpa_s);
00321 }
00322 
00323 
00324 void wpas_notify_resume(struct wpa_global *global)
00325 {
00326         struct os_time now;
00327         int slept;
00328         struct wpa_supplicant *wpa_s;
00329 
00330         if (global->suspend_time.sec == 0)
00331                 slept = -1;
00332         else {
00333                 os_get_time(&now);
00334                 slept = now.sec - global->suspend_time.sec;
00335         }
00336         wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
00337                    slept);
00338 
00339         for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
00340                 wpa_drv_resume(wpa_s);
00341                 if (wpa_s->wpa_state == WPA_DISCONNECTED)
00342                         wpa_supplicant_req_scan(wpa_s, 0, 100000);
00343         }
00344 }


wpa_supplicant_node
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Jan 2 2014 11:25:14