wpa_supplicant and dbus code separation

This patch completely separates supplicant's code from dbus.
It introduces three new notifications which copes with all
remaining dbus stuff.
wpas_notify_unregister_interface() was renamed to
wpas_notify_iface_removed().
This commit is contained in:
Witold Sowa 2009-10-15 21:15:10 +03:00 committed by Jouni Malinen
parent 4f34d51abe
commit dc461de43e
3 changed files with 48 additions and 21 deletions

View file

@ -21,6 +21,42 @@
#include "ctrl_iface_dbus.h"
#include "notify.h"
int wpas_notify_supplicant_initialized(struct wpa_global *global)
{
if (global->params.dbus_ctrl_interface) {
global->dbus_ctrl_iface =
wpa_supplicant_dbus_ctrl_iface_init(global);
if (global->dbus_ctrl_iface == NULL)
return -1;
}
return 0;
}
void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
{
if (global->dbus_ctrl_iface)
wpa_supplicant_dbus_ctrl_iface_deinit(global->dbus_ctrl_iface);
}
int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
{
if (wpas_dbus_register_iface(wpa_s))
return -1;
return 0;
}
void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
{
/* unregister interface in old DBus ctrl iface */
wpas_dbus_unregister_iface(wpa_s);
}
void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
wpa_states new_state, wpa_states old_state)
@ -58,13 +94,6 @@ void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
}
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 */

View file

@ -19,6 +19,10 @@ struct wps_credential;
struct wps_event_m2d;
struct wps_event_fail;
int wpas_notify_supplicant_initialized(struct wpa_global *global);
void wpas_notify_supplicant_deinitialized(struct wpa_global *global);
int wpas_notify_iface_added(struct wpa_supplicant *wpa_s);
void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s);
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);
@ -28,7 +32,6 @@ 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);

View file

@ -29,7 +29,6 @@
#include "wpa_supplicant_i.h"
#include "driver_i.h"
#include "ctrl_iface.h"
#include "ctrl_iface_dbus.h"
#include "pcsc_funcs.h"
#include "version.h"
#include "preauth.h"
@ -2222,7 +2221,7 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s)
wpa_clear_keys(wpa_s, NULL);
}
wpas_notify_unregister_interface(wpa_s);
wpas_notify_iface_removed(wpa_s);
wpa_supplicant_cleanup(wpa_s);
@ -2265,8 +2264,8 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
wpa_s->global = global;
/* Register the interface with the dbus control interface */
if (wpas_dbus_register_iface(wpa_s)) {
/* Notify the control interfaces about new iface */
if (wpas_notify_iface_added(wpa_s)) {
wpa_supplicant_deinit_iface(wpa_s);
os_free(wpa_s);
return NULL;
@ -2408,13 +2407,9 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
return NULL;
}
if (global->params.dbus_ctrl_interface) {
global->dbus_ctrl_iface =
wpa_supplicant_dbus_ctrl_iface_init(global);
if (global->dbus_ctrl_iface == NULL) {
wpa_supplicant_deinit(global);
return NULL;
}
if (wpas_notify_supplicant_initialized(global)) {
wpa_supplicant_deinit(global);
return NULL;
}
for (i = 0; wpa_drivers[i]; i++)
@ -2497,8 +2492,8 @@ void wpa_supplicant_deinit(struct wpa_global *global)
if (global->ctrl_iface)
wpa_supplicant_global_ctrl_iface_deinit(global->ctrl_iface);
if (global->dbus_ctrl_iface)
wpa_supplicant_dbus_ctrl_iface_deinit(global->dbus_ctrl_iface);
wpas_notify_supplicant_deinitialized(global);
eap_peer_unregister_methods();
#ifdef CONFIG_AP