hostap/wpa_supplicant/dbus/dbus_new_handlers.h
Dan Williams 6aeeb6fa21 dbus: clean up new D-Bus interface getters and setters
A number of fixes/improvements here:

1) Remove casting of getter/setter function types which allows
us to change the prototypes in the future and not have hard-to-find
runtime segfaults

2) Instead of having the getters create a fake reply message which
then gets its arguments copied into the real reply message, and is
then disposed, just pass message iters around and have them add
their arguments to the message itself

3) For setters, just pass in the message iter positioned at the
start of the argument list, instead of each setter having to skip
over the standard interface+property name

4) Convert error handling to use DBusError and return the error
back down through the call stacks to the function that will
actually send the error back to the caller, instead of having a
fake DBusMessage of type DBUS_MESSAGE_TYPE_ERROR that then
needs to have the error extracted from it.

But most of all, this fixes various segfaults (like rh #725517
and #678625) which were caused by some functions deep down in the
getter callpaths wanting a source DBusMessage* when the getters were
used for two things: signals (which don't have a source DBusMessage)
and methods (which will have a source DBusMessage that's being
replied to).  This duality made the code fragile when handling
errors like invalid IEs over the air.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2011-07-29 21:25:39 +03:00

245 lines
7.9 KiB
C

/*
* WPA Supplicant / dbus-based control interface
* Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
* Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
*
* 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 CTRL_IFACE_DBUS_NEW_HANDLERS_H
#define CTRL_IFACE_DBUS_NEW_HANDLERS_H
struct network_handler_args {
struct wpa_supplicant *wpa_s;
struct wpa_ssid *ssid;
};
struct bss_handler_args {
struct wpa_supplicant *wpa_s;
unsigned int id;
};
dbus_bool_t wpas_dbus_simple_property_getter(DBusMessageIter *iter,
const int type,
const void *val,
DBusError *error);
dbus_bool_t wpas_dbus_simple_property_setter(DBusMessageIter *iter,
DBusError *error,
const int type, void *val);
dbus_bool_t wpas_dbus_simple_array_property_getter(DBusMessageIter *iter,
const int type,
const void *array,
size_t array_len,
DBusError *error);
DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_handler_remove_interface(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_handler_get_interface(DBusMessage *message,
struct wpa_global *global);
dbus_bool_t wpas_dbus_getter_debug_level(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_debug_timestamp(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_debug_show_keys(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_debug_level(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_setter_debug_timestamp(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_debug_show_keys(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_interfaces(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_eap_methods(DBusMessageIter *iter,
DBusError *error, void *user_data);
DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_disconnect(DBusMessage *message,
struct wpa_supplicant *wpa_s);
dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid,
DBusMessageIter *iter,
DBusError *error);
DBusMessage * wpas_dbus_handler_add_network(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_remove_all_networks(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_select_network(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_add_blob(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_get_blob(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_remove_blob(DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_flush_bss(DBusMessage *message,
struct wpa_supplicant *wpa_s);
dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_getter_state(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_scanning(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_ap_scan(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_ap_scan(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bss_expire_age(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_setter_bss_expire_age(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bss_expire_count(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_bss_expire_count(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_country(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_country(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_ifname(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_driver(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bridge_ifname(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_current_bss(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_current_network(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_current_auth_mode(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bsss(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_networks(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_blobs(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bss_bssid(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bss_ssid(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bss_privacy(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_getter_bss_mode(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bss_signal(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_getter_bss_frequency(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_getter_bss_rates(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_getter_bss_wpa(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bss_rsn(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_bss_ies(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_enabled(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_enabled(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_network_properties(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_network_properties(DBusMessageIter *iter,
DBusError *error,
void *user_data);
DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
struct wpa_supplicant *wpa_s);
dbus_bool_t wpas_dbus_getter_process_credentials(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_setter_process_credentials(DBusMessageIter *iter,
DBusError *error,
void *user_data);
DBusMessage * wpas_dbus_error_invalid_args(DBusMessage *message,
const char *arg);
DBusMessage * wpas_dbus_error_unknown_error(DBusMessage *message,
const char *arg);
#endif /* CTRL_IFACE_DBUS_HANDLERS_NEW_H */