2009-11-09 22:51:59 +01:00
|
|
|
/*
|
|
|
|
* WPA Supplicant / dbus-based control interface
|
|
|
|
* Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
|
|
|
|
* Copyright (c) 2009, Witold Sowa <witold.sowa@gmail.com>
|
|
|
|
*
|
2012-07-02 11:04:38 +02:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2009-11-09 22:51:59 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WPA_DBUS_CTRL_H
|
|
|
|
#define WPA_DBUS_CTRL_H
|
|
|
|
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
2014-12-31 22:21:10 +01:00
|
|
|
typedef DBusMessage * (*WPADBusMethodHandler)(DBusMessage *message,
|
|
|
|
void *user_data);
|
|
|
|
typedef void (*WPADBusArgumentFreeFunction)(void *handler_arg);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2015-10-13 18:45:33 +02:00
|
|
|
struct wpa_dbus_property_desc;
|
|
|
|
typedef dbus_bool_t (*WPADBusPropertyAccessor)(
|
|
|
|
const struct wpa_dbus_property_desc *property_desc,
|
|
|
|
DBusMessageIter *iter, DBusError *error, void *user_data);
|
|
|
|
#define DECLARE_ACCESSOR(f) \
|
|
|
|
dbus_bool_t f(const struct wpa_dbus_property_desc *property_desc, \
|
|
|
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
struct wpa_dbus_object_desc {
|
|
|
|
DBusConnection *connection;
|
2010-01-04 16:15:57 +01:00
|
|
|
char *path;
|
2010-01-01 10:33:41 +01:00
|
|
|
|
|
|
|
/* list of methods, properties and signals registered with object */
|
2010-01-02 23:52:30 +01:00
|
|
|
const struct wpa_dbus_method_desc *methods;
|
|
|
|
const struct wpa_dbus_signal_desc *signals;
|
|
|
|
const struct wpa_dbus_property_desc *properties;
|
2010-01-01 10:33:41 +01:00
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
/* property changed flags */
|
|
|
|
u8 *prop_changed_flags;
|
|
|
|
|
2010-01-01 10:33:41 +01:00
|
|
|
/* argument for method handlers and properties
|
|
|
|
* getter and setter functions */
|
|
|
|
void *user_data;
|
|
|
|
/* function used to free above argument */
|
|
|
|
WPADBusArgumentFreeFunction user_data_free_func;
|
2009-11-09 22:51:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum dbus_arg_direction { ARG_IN, ARG_OUT };
|
|
|
|
|
|
|
|
struct wpa_dbus_argument {
|
|
|
|
char *name;
|
|
|
|
char *type;
|
|
|
|
enum dbus_arg_direction dir;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define END_ARGS { NULL, NULL, ARG_IN }
|
|
|
|
|
2010-01-01 13:03:00 +01:00
|
|
|
/**
|
|
|
|
* struct wpa_dbus_method_desc - DBus method description
|
|
|
|
*/
|
|
|
|
struct wpa_dbus_method_desc {
|
|
|
|
/* method name */
|
2010-01-02 23:52:30 +01:00
|
|
|
const char *dbus_method;
|
|
|
|
/* method interface */
|
|
|
|
const char *dbus_interface;
|
2010-01-01 13:03:00 +01:00
|
|
|
/* method handling function */
|
|
|
|
WPADBusMethodHandler method_handler;
|
|
|
|
/* array of arguments */
|
2011-10-24 18:09:06 +02:00
|
|
|
struct wpa_dbus_argument args[4];
|
2010-01-01 13:03:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct wpa_dbus_signal_desc - DBus signal description
|
|
|
|
*/
|
|
|
|
struct wpa_dbus_signal_desc {
|
|
|
|
/* signal name */
|
2010-01-02 23:52:30 +01:00
|
|
|
const char *dbus_signal;
|
|
|
|
/* signal interface */
|
|
|
|
const char *dbus_interface;
|
2010-01-01 13:03:00 +01:00
|
|
|
/* array of arguments */
|
2011-10-24 18:03:04 +02:00
|
|
|
struct wpa_dbus_argument args[4];
|
2010-01-01 13:03:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct wpa_dbus_property_desc - DBus property description
|
|
|
|
*/
|
|
|
|
struct wpa_dbus_property_desc {
|
|
|
|
/* property name */
|
2010-01-02 23:52:30 +01:00
|
|
|
const char *dbus_property;
|
|
|
|
/* property interface */
|
|
|
|
const char *dbus_interface;
|
2010-01-01 13:03:00 +01:00
|
|
|
/* property type signature in DBus type notation */
|
2010-01-02 23:52:30 +01:00
|
|
|
const char *type;
|
2010-01-01 13:03:00 +01:00
|
|
|
/* property getter function */
|
|
|
|
WPADBusPropertyAccessor getter;
|
|
|
|
/* property setter function */
|
|
|
|
WPADBusPropertyAccessor setter;
|
2015-10-13 18:47:46 +02:00
|
|
|
/* other data */
|
|
|
|
const char *data;
|
2010-01-01 13:03:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
#define WPAS_DBUS_OBJECT_PATH_MAX 150
|
|
|
|
#define WPAS_DBUS_INTERFACE_MAX 150
|
|
|
|
#define WPAS_DBUS_METHOD_SIGNAL_PROP_MAX 50
|
2011-03-15 12:53:56 +01:00
|
|
|
#define WPAS_DBUS_AUTH_MODE_MAX 64
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
#define WPA_DBUS_INTROSPECTION_INTERFACE "org.freedesktop.DBus.Introspectable"
|
|
|
|
#define WPA_DBUS_INTROSPECTION_METHOD "Introspect"
|
|
|
|
#define WPA_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
|
|
|
|
#define WPA_DBUS_PROPERTIES_GET "Get"
|
|
|
|
#define WPA_DBUS_PROPERTIES_SET "Set"
|
|
|
|
#define WPA_DBUS_PROPERTIES_GETALL "GetAll"
|
|
|
|
|
|
|
|
void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc);
|
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface, char *dbus_path,
|
|
|
|
char *dbus_service,
|
|
|
|
struct wpa_dbus_object_desc *obj_desc);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
int wpa_dbus_register_object_per_iface(
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface,
|
2009-11-09 22:51:59 +01:00
|
|
|
const char *path, const char *ifname,
|
|
|
|
struct wpa_dbus_object_desc *obj_desc);
|
|
|
|
|
|
|
|
int wpa_dbus_unregister_object_per_iface(
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface,
|
2009-11-09 22:51:59 +01:00
|
|
|
const char *path);
|
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
dbus_bool_t wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface,
|
|
|
|
const char *path,
|
|
|
|
const char *interface,
|
|
|
|
DBusMessageIter *iter);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
|
|
|
|
void wpa_dbus_flush_all_changed_properties(DBusConnection *con);
|
|
|
|
|
|
|
|
void wpa_dbus_flush_object_changed_properties(DBusConnection *con,
|
|
|
|
const char *path);
|
|
|
|
|
|
|
|
void wpa_dbus_mark_property_changed(struct wpas_dbus_priv *iface,
|
|
|
|
const char *path, const char *interface,
|
|
|
|
const char *property);
|
|
|
|
|
2010-01-01 13:03:00 +01:00
|
|
|
DBusMessage * wpa_dbus_introspect(DBusMessage *message,
|
|
|
|
struct wpa_dbus_object_desc *obj_dsc);
|
|
|
|
|
2015-01-01 10:42:32 +01:00
|
|
|
char * wpas_dbus_new_decompose_object_path(const char *path, const char *sep,
|
|
|
|
char **item);
|
2011-06-12 23:41:41 +02:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusMessage *wpas_dbus_reply_new_from_error(DBusMessage *message,
|
|
|
|
DBusError *error,
|
|
|
|
const char *fallback_name,
|
|
|
|
const char *fallback_string);
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
#endif /* WPA_DBUS_CTRL_H */
|