wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
dbus_new_helpers.c File Reference

WPA Supplicant / dbus-based control interface Copyright (c) 2009, Witold Sowa witol.nosp@m.d.so.nosp@m.wa@gm.nosp@m.ail..nosp@m.com More...

#include "utils/includes.h"
#include "utils/common.h"
#include "utils/eloop.h"
#include "dbus_common.h"
#include "dbus_common_i.h"
#include "dbus_new.h"
#include "dbus_new_helpers.h"
#include "dbus_new_handlers.h"
#include "dbus_dict_helpers.h"

Macros

#define MAX_SIG_LEN   256
 
#define WPA_DBUS_SEND_PROP_CHANGED_TIMEOUT   5000
 

Functions

void free_dbus_object_desc (struct wpa_dbus_object_desc *obj_dsc)
 Frees object description data structure. More...
 
int wpa_dbus_ctrl_iface_init (struct wpas_dbus_priv *iface, char *dbus_path, char *dbus_service, struct wpa_dbus_object_desc *obj_desc)
 Initialize dbus control interface. More...
 
int wpa_dbus_register_object_per_iface (struct wpas_dbus_priv *ctrl_iface, const char *path, const char *ifname, struct wpa_dbus_object_desc *obj_desc)
 Register a new object with dbus. More...
 
int wpa_dbus_unregister_object_per_iface (struct wpas_dbus_priv *ctrl_iface, const char *path)
 Unregisters DBus object. More...
 
void wpa_dbus_flush_all_changed_properties (DBusConnection *con)
 Send all PropertiesChanged signals. More...
 
void wpa_dbus_flush_object_changed_properties (DBusConnection *con, const char *path)
 Send PropertiesChanged for object. More...
 
void wpa_dbus_mark_property_changed (struct wpas_dbus_priv *iface, const char *path, const char *interface, const char *property)
 Mark a property as changed and. More...
 
dbus_bool_t wpa_dbus_get_object_properties (struct wpas_dbus_priv *iface, const char *path, const char *interface, DBusMessageIter *iter)
 Put object's properties into dictionary. More...
 
char * wpas_dbus_new_decompose_object_path (const char *path, const char *sep, char **item)
 Decompose an interface object path into parts. More...
 
DBusMessage * wpas_dbus_reply_new_from_error (DBusMessage *message, DBusError *error, const char *fallback_name, const char *fallback_string)
 Create a new D-Bus error message from a dbus error structure. More...
 

Detailed Description

WPA Supplicant / dbus-based control interface Copyright (c) 2009, Witold Sowa witol.nosp@m.d.so.nosp@m.wa@gm.nosp@m.ail..nosp@m.com

Function Documentation

void free_dbus_object_desc ( struct wpa_dbus_object_desc obj_dsc)

Frees object description data structure.

Parameters
connectionDBus connection
obj_dscObject description to free

Frees each of properties, methods and signals description lists and the object description structure itself.

int wpa_dbus_ctrl_iface_init ( struct wpas_dbus_priv iface,
char *  dbus_path,
char *  dbus_service,
struct wpa_dbus_object_desc obj_desc 
)

Initialize dbus control interface.

Parameters
application_dataPointer to application specific data structure
dbus_pathDBus path to interface object
dbus_serviceDBus service name to register with
messageHandlera pointer to function which will handle dbus messages coming on interface
Returns
0 on success, -1 on failure

Initialize the dbus control interface and start receiving commands from external programs over the bus.

void wpa_dbus_flush_all_changed_properties ( DBusConnection *  con)

Send all PropertiesChanged signals.

Parameters
conDBus connection

Traverses through all registered objects and sends PropertiesChanged for each properties.

void wpa_dbus_flush_object_changed_properties ( DBusConnection *  con,
const char *  path 
)

Send PropertiesChanged for object.

Parameters
conDBus connection
pathpath to a DBus object for which PropertiesChanged will be sent.

Iterates over all properties registered with object and for each interface containing properties marked as changed, sends a PropertiesChanged signal containing names and new values of properties that have changed.

You need to call this function after wpa_dbus_mark_property_changed() if you want to send PropertiesChanged signal immediately (i.e., without waiting timeout to expire). PropertiesChanged signal for an object is sent automatically short time after first marking property as changed. All PropertiesChanged signals are sent automatically after responding on DBus message, so if you marked a property changed as a result of DBus call (e.g., param setter), you usually do not need to call this function.

dbus_bool_t wpa_dbus_get_object_properties ( struct wpas_dbus_priv iface,
const char *  path,
const char *  interface,
DBusMessageIter *  iter 
)

Put object's properties into dictionary.

Parameters
ifacedbus priv struct
pathpath to DBus object which properties will be obtained
interfaceinterface name which properties will be obtained
iterDBus message iter at which to append property dictionary.

Iterates over all properties registered with object and execute getters of those, which are readable and which interface matches interface specified as argument. Obtained properties values are stored in dict_iter dictionary.

void wpa_dbus_mark_property_changed ( struct wpas_dbus_priv iface,
const char *  path,
const char *  interface,
const char *  property 
)

Mark a property as changed and.

Parameters
ifacedbus priv struct
pathpath to DBus object which property has changed
interfaceinterface containing changed property
propertyproperty name which has changed

Iterates over all properties registered with an object and marks the one given in parameters as changed. All parameters registered for an object within a single interface will be aggregated together and sent in one PropertiesChanged signal when function wpa_dbus_flush_object_changed_properties() is called.

int wpa_dbus_register_object_per_iface ( struct wpas_dbus_priv ctrl_iface,
const char *  path,
const char *  ifname,
struct wpa_dbus_object_desc obj_desc 
)

Register a new object with dbus.

Parameters
ctrl_ifacepointer to dbus private data
pathDBus path to object
ifnameinterface name
obj_descdescription of object's methods, signals and properties
Returns
0 on success, -1 on error

Registers a new interface with dbus and assigns it a dbus object path.

int wpa_dbus_unregister_object_per_iface ( struct wpas_dbus_priv ctrl_iface,
const char *  path 
)

Unregisters DBus object.

Parameters
ctrl_ifacePointer to dbus private data
pathDBus path to object which will be unregistered
Returns
Zero on success and -1 on failure

Unregisters DBus object given by its path

char* wpas_dbus_new_decompose_object_path ( const char *  path,
const char *  sep,
char **  item 
)

Decompose an interface object path into parts.

Parameters
pathThe dbus object path
sepSeparating part (e.g., "Networks" or "PersistentGroups")
item(out) The part following the specified separator, if any
Returns
The object path of the interface this path refers to

For a given object path, decomposes the object path into object id and requested part, if those parts exist. The caller is responsible for freeing the returned value. The *item pointer points to that allocated value and must not be freed separately.

As an example, path = "/fi/w1/wpa_supplicant1/Interfaces/1/Networks/0" and sep = "Networks" would result in "/fi/w1/wpa_supplicant1/Interfaces/1" getting returned and *items set to point to "0".

DBusMessage* wpas_dbus_reply_new_from_error ( DBusMessage *  message,
DBusError *  error,
const char *  fallback_name,
const char *  fallback_string 
)

Create a new D-Bus error message from a dbus error structure.

Parameters
messageThe original request message for which the error is a reply
errorThe error containing a name and a descriptive error cause
fallback_nameA generic error name if error was not set
fallback_stringA generic error string if error was not set
Returns
A new D-Bus error message

Given a DBusMessage structure, creates a new D-Bus error message using the error name and string contained in that structure.