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


wpa_supplicant
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Apr 24 2014 15:34:35