hostap/wpa_supplicant/dbus/dbus_new_handlers_p2p.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

170 lines
4.9 KiB
C

/*
* WPA Supplicant / dbus-based control interface for p2p
*
* 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 DBUS_NEW_HANDLERS_P2P_H
#define DBUS_NEW_HANDLERS_P2P_H
struct peer_handler_args {
struct wpa_supplicant *wpa_s;
u8 p2p_device_addr[ETH_ALEN];
};
struct groupmember_handler_args {
struct wpa_supplicant *wpa_s;
u8 member_addr[ETH_ALEN];
};
/*
* P2P Device methods
*/
DBusMessage *wpas_dbus_handler_p2p_find(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_stop_find(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_rejectpeer(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_listen(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_extendedlisten(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_presence_request(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_prov_disc_req(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_group_add(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_connect(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_invite(
DBusMessage *message,
struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_disconnect(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_flush(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_add_service(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_delete_service(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_flush_service(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_service_sd_req(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_service_sd_res(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_service_sd_cancel_req(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_service_update(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage *wpas_dbus_handler_p2p_serv_disc_external(
DBusMessage *message, struct wpa_supplicant *wpa_s);
/*
* P2P Device property accessor methods.
*/
dbus_bool_t wpas_dbus_setter_p2p_device_properties(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_p2p_device_properties(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_p2p_peers(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_p2p_role(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_p2p_group(DBusMessageIter *iter, DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_p2p_peergo(DBusMessageIter *iter,
DBusError *error,
void *user_data);
/*
* P2P Peer properties.
*/
dbus_bool_t wpas_dbus_getter_p2p_peer_properties(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_p2p_peer_ies(DBusMessageIter *iter,
DBusError *error,
void *user_data);
/*
* P2P Group properties
*/
dbus_bool_t wpas_dbus_getter_p2p_group_members(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_p2p_group_properties(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_setter_p2p_group_properties(DBusMessageIter *iter,
DBusError *error,
void *user_data);
/*
* P2P Persistent Groups and properties
*/
dbus_bool_t wpas_dbus_getter_persistent_groups(DBusMessageIter *iter,
DBusError *error,
void *user_data);
dbus_bool_t wpas_dbus_getter_persistent_group_properties(DBusMessageIter *iter,
DBusError *error, void *user_data);
dbus_bool_t wpas_dbus_setter_persistent_group_properties(DBusMessageIter *iter,
DBusError *error,
void *user_data);
DBusMessage * wpas_dbus_handler_add_persistent_group(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_remove_persistent_group(
DBusMessage *message, struct wpa_supplicant *wpa_s);
DBusMessage * wpas_dbus_handler_remove_all_persistent_groups(
DBusMessage *message, struct wpa_supplicant *wpa_s);
#endif /* DBUS_NEW_HANDLERS_P2P_H */