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
|
|
|
*/
|
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
#include "utils/includes.h"
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
#include "utils/common.h"
|
|
|
|
#include "utils/eloop.h"
|
2022-12-01 00:33:10 +01:00
|
|
|
#include "drivers/driver.h"
|
2009-12-30 23:15:56 +01:00
|
|
|
#include "dbus_common.h"
|
|
|
|
#include "dbus_common_i.h"
|
2010-01-04 16:15:57 +01:00
|
|
|
#include "dbus_new.h"
|
2009-12-20 20:11:35 +01:00
|
|
|
#include "dbus_new_helpers.h"
|
2015-01-01 21:36:52 +01:00
|
|
|
#include "dbus_new_handlers.h"
|
2011-07-29 20:25:39 +02:00
|
|
|
#include "dbus_dict_helpers.h"
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
static dbus_bool_t fill_dict_with_properties(
|
|
|
|
DBusMessageIter *dict_iter,
|
|
|
|
const struct wpa_dbus_property_desc *props,
|
|
|
|
const char *interface, void *user_data, DBusError *error)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusMessageIter entry_iter;
|
2010-01-02 23:52:30 +01:00
|
|
|
const struct wpa_dbus_property_desc *dsc;
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
for (dsc = props; dsc && dsc->dbus_property; dsc++) {
|
2011-07-29 20:25:39 +02:00
|
|
|
/* Only return properties for the requested D-Bus interface */
|
|
|
|
if (os_strncmp(dsc->dbus_interface, interface,
|
|
|
|
WPAS_DBUS_INTERFACE_MAX) != 0)
|
|
|
|
continue;
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2011-08-07 10:16:05 +02:00
|
|
|
/* Skip write-only properties */
|
|
|
|
if (dsc->getter == NULL)
|
2011-07-29 20:25:39 +02:00
|
|
|
continue;
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
if (!dbus_message_iter_open_container(dict_iter,
|
|
|
|
DBUS_TYPE_DICT_ENTRY,
|
2014-06-14 00:29:42 +02:00
|
|
|
NULL, &entry_iter) ||
|
|
|
|
!dbus_message_iter_append_basic(&entry_iter,
|
2011-07-29 20:25:39 +02:00
|
|
|
DBUS_TYPE_STRING,
|
2014-06-14 00:29:42 +02:00
|
|
|
&dsc->dbus_property))
|
|
|
|
goto error;
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
/* An error getting a property fails the request entirely */
|
2015-10-13 18:45:33 +02:00
|
|
|
if (!dsc->getter(dsc, &entry_iter, error, user_data)) {
|
2015-04-29 19:43:23 +02:00
|
|
|
wpa_printf(MSG_INFO,
|
|
|
|
"dbus: %s dbus_interface=%s dbus_property=%s getter failed",
|
|
|
|
__func__, dsc->dbus_interface,
|
|
|
|
dsc->dbus_property);
|
2011-07-29 20:25:39 +02:00
|
|
|
return FALSE;
|
2015-04-29 19:43:23 +02:00
|
|
|
}
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2014-06-14 00:29:42 +02:00
|
|
|
if (!dbus_message_iter_close_container(dict_iter, &entry_iter))
|
|
|
|
goto error;
|
2010-01-01 11:47:59 +01:00
|
|
|
}
|
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
return TRUE;
|
2014-06-14 00:29:42 +02:00
|
|
|
|
|
|
|
error:
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
2010-01-01 11:47:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
/**
|
|
|
|
* get_all_properties - Responds for GetAll properties calls on object
|
|
|
|
* @message: Message with GetAll call
|
|
|
|
* @interface: interface name which properties will be returned
|
|
|
|
* @property_dsc: list of object's properties
|
|
|
|
* Returns: Message with dict of variants as argument with properties values
|
|
|
|
*
|
|
|
|
* Iterates over all properties registered with object and execute getters
|
|
|
|
* of those, which are readable and which interface matches interface
|
|
|
|
* specified as argument. Returned message contains one dict argument
|
|
|
|
* with properties names as keys and theirs values as values.
|
|
|
|
*/
|
2011-07-29 20:25:39 +02:00
|
|
|
static DBusMessage * get_all_properties(DBusMessage *message, char *interface,
|
2014-12-31 22:21:10 +01:00
|
|
|
struct wpa_dbus_object_desc *obj_dsc)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusMessage *reply;
|
2010-01-01 11:47:59 +01:00
|
|
|
DBusMessageIter iter, dict_iter;
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusError error;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
reply = dbus_message_new_method_return(message);
|
2015-01-01 21:36:52 +01:00
|
|
|
if (reply == NULL)
|
|
|
|
return wpas_dbus_error_no_memory(message);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
dbus_message_iter_init_append(reply, &iter);
|
|
|
|
if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) {
|
|
|
|
dbus_message_unref(reply);
|
2015-01-01 21:36:52 +01:00
|
|
|
return wpas_dbus_error_no_memory(message);
|
2011-07-29 20:25:39 +02:00
|
|
|
}
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
dbus_error_init(&error);
|
|
|
|
if (!fill_dict_with_properties(&dict_iter, obj_dsc->properties,
|
2014-12-31 22:21:10 +01:00
|
|
|
interface, obj_dsc->user_data, &error)) {
|
2019-05-08 21:06:46 +02:00
|
|
|
wpa_dbus_dict_close_write(&iter, &dict_iter);
|
2009-11-09 22:51:59 +01:00
|
|
|
dbus_message_unref(reply);
|
2014-12-31 22:21:10 +01:00
|
|
|
reply = wpas_dbus_reply_new_from_error(
|
|
|
|
message, &error, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"No readable properties in this interface");
|
2011-07-29 20:25:39 +02:00
|
|
|
dbus_error_free(&error);
|
|
|
|
return reply;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
2014-06-14 00:29:42 +02:00
|
|
|
if (!wpa_dbus_dict_close_write(&iter, &dict_iter)) {
|
|
|
|
dbus_message_unref(reply);
|
2015-01-01 21:36:52 +01:00
|
|
|
return wpas_dbus_error_no_memory(message);
|
2014-06-14 00:29:42 +02:00
|
|
|
}
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
return reply;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-10 17:29:38 +01:00
|
|
|
static int is_signature_correct(DBusMessage *message,
|
2010-01-02 23:52:30 +01:00
|
|
|
const struct wpa_dbus_method_desc *method_dsc)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
/* According to DBus documentation max length of signature is 255 */
|
2009-11-10 17:29:38 +01:00
|
|
|
#define MAX_SIG_LEN 256
|
|
|
|
char registered_sig[MAX_SIG_LEN], *pos;
|
2009-11-09 22:51:59 +01:00
|
|
|
const char *sig = dbus_message_get_signature(message);
|
2010-01-02 23:52:30 +01:00
|
|
|
int ret;
|
|
|
|
const struct wpa_dbus_argument *arg;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-11-10 17:29:38 +01:00
|
|
|
pos = registered_sig;
|
|
|
|
*pos = '\0';
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
for (arg = method_dsc->args; arg && arg->name; arg++) {
|
|
|
|
if (arg->dir == ARG_IN) {
|
2009-11-10 17:29:38 +01:00
|
|
|
size_t blen = registered_sig + MAX_SIG_LEN - pos;
|
2014-12-31 22:21:10 +01:00
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
ret = os_snprintf(pos, blen, "%s", arg->type);
|
Check os_snprintf() result more consistently - automatic 1
This converts os_snprintf() result validation cases to use
os_snprintf_error() where the exact rule used in os_snprintf_error() was
used. These changes were done automatically with spatch using the
following semantic patch:
@@
identifier E1;
expression E2,E3,E4,E5,E6;
statement S1;
@@
(
E1 = os_snprintf(E2, E3, ...);
|
int E1 = os_snprintf(E2, E3, ...);
|
if (E5)
E1 = os_snprintf(E2, E3, ...);
else
E1 = os_snprintf(E2, E3, ...);
|
if (E5)
E1 = os_snprintf(E2, E3, ...);
else if (E6)
E1 = os_snprintf(E2, E3, ...);
else
E1 = 0;
|
if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
} else {
...
return -1;
}
|
if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
} else if (E6) {
...
E1 = os_snprintf(E2, E3, ...);
} else {
...
return -1;
}
|
if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
} else {
...
E1 = os_snprintf(E2, E3, ...);
}
)
? os_free(E4);
- if (E1 < 0 || \( E1 >= E3 \| (size_t) E1 >= E3 \| (unsigned int) E1 >= E3 \| E1 >= (int) E3 \))
+ if (os_snprintf_error(E3, E1))
(
S1
|
{ ... }
)
Signed-off-by: Jouni Malinen <j@w1.fi>
2014-12-08 10:15:51 +01:00
|
|
|
if (os_snprintf_error(blen, ret))
|
2009-11-10 17:29:38 +01:00
|
|
|
return 0;
|
|
|
|
pos += ret;
|
|
|
|
}
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return !os_strncmp(registered_sig, sig, MAX_SIG_LEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-26 20:26:56 +01:00
|
|
|
static DBusMessage * properties_get_all(DBusMessage *message, char *interface,
|
|
|
|
struct wpa_dbus_object_desc *obj_dsc)
|
|
|
|
{
|
|
|
|
if (os_strcmp(dbus_message_get_signature(message), "s") != 0)
|
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
NULL);
|
|
|
|
|
2010-01-01 10:33:41 +01:00
|
|
|
return get_all_properties(message, interface, obj_dsc);
|
2009-12-26 20:26:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DBusMessage * properties_get(DBusMessage *message,
|
2010-01-02 23:52:30 +01:00
|
|
|
const struct wpa_dbus_property_desc *dsc,
|
2010-01-01 10:33:41 +01:00
|
|
|
void *user_data)
|
2009-12-26 20:26:56 +01:00
|
|
|
{
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusMessage *reply;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
if (os_strcmp(dbus_message_get_signature(message), "ss")) {
|
2009-12-26 20:26:56 +01:00
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
NULL);
|
2011-07-29 20:25:39 +02:00
|
|
|
}
|
2009-12-26 20:26:56 +01:00
|
|
|
|
2011-08-07 10:16:05 +02:00
|
|
|
if (dsc->getter == NULL) {
|
2011-07-29 20:25:39 +02:00
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"Property is write-only");
|
|
|
|
}
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(message);
|
|
|
|
dbus_message_iter_init_append(reply, &iter);
|
2009-12-26 20:26:56 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
dbus_error_init(&error);
|
2015-10-13 18:45:33 +02:00
|
|
|
if (dsc->getter(dsc, &iter, &error, user_data) == FALSE) {
|
2011-07-29 20:25:39 +02:00
|
|
|
dbus_message_unref(reply);
|
|
|
|
reply = wpas_dbus_reply_new_from_error(
|
|
|
|
message, &error, DBUS_ERROR_FAILED,
|
|
|
|
"Failed to read property");
|
|
|
|
dbus_error_free(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return reply;
|
2009-12-26 20:26:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DBusMessage * properties_set(DBusMessage *message,
|
2010-01-02 23:52:30 +01:00
|
|
|
const struct wpa_dbus_property_desc *dsc,
|
2010-01-01 10:33:41 +01:00
|
|
|
void *user_data)
|
2009-12-26 20:26:56 +01:00
|
|
|
{
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusMessage *reply;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
if (os_strcmp(dbus_message_get_signature(message), "ssv")) {
|
2009-12-26 20:26:56 +01:00
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
NULL);
|
2011-07-29 20:25:39 +02:00
|
|
|
}
|
|
|
|
|
2011-08-07 10:16:05 +02:00
|
|
|
if (dsc->setter == NULL) {
|
2011-07-29 20:25:39 +02:00
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"Property is read-only");
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
/* Skip the interface name and the property name */
|
|
|
|
dbus_message_iter_next(&iter);
|
|
|
|
dbus_message_iter_next(&iter);
|
2009-12-26 20:26:56 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
/* Iter will now point to the property's new value */
|
|
|
|
dbus_error_init(&error);
|
2015-10-13 18:45:33 +02:00
|
|
|
if (dsc->setter(dsc, &iter, &error, user_data) == TRUE) {
|
2011-07-29 20:25:39 +02:00
|
|
|
/* Success */
|
|
|
|
reply = dbus_message_new_method_return(message);
|
|
|
|
} else {
|
|
|
|
reply = wpas_dbus_reply_new_from_error(
|
|
|
|
message, &error, DBUS_ERROR_FAILED,
|
|
|
|
"Failed to set property");
|
|
|
|
dbus_error_free(&error);
|
|
|
|
}
|
2009-12-26 20:26:56 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
return reply;
|
2009-12-26 20:26:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DBusMessage *
|
|
|
|
properties_get_or_set(DBusMessage *message, DBusMessageIter *iter,
|
|
|
|
char *interface,
|
|
|
|
struct wpa_dbus_object_desc *obj_dsc)
|
|
|
|
{
|
2010-01-02 23:52:30 +01:00
|
|
|
const struct wpa_dbus_property_desc *property_dsc;
|
2009-12-26 20:26:56 +01:00
|
|
|
char *property;
|
|
|
|
const char *method;
|
|
|
|
|
|
|
|
method = dbus_message_get_member(message);
|
|
|
|
property_dsc = obj_dsc->properties;
|
|
|
|
|
|
|
|
/* Second argument: property name (DBUS_TYPE_STRING) */
|
|
|
|
if (!dbus_message_iter_next(iter) ||
|
|
|
|
dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING) {
|
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
dbus_message_iter_get_basic(iter, &property);
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
while (property_dsc && property_dsc->dbus_property) {
|
2009-12-26 20:26:56 +01:00
|
|
|
/* compare property names and
|
|
|
|
* interfaces */
|
|
|
|
if (!os_strncmp(property_dsc->dbus_property, property,
|
|
|
|
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX) &&
|
|
|
|
!os_strncmp(property_dsc->dbus_interface, interface,
|
|
|
|
WPAS_DBUS_INTERFACE_MAX))
|
|
|
|
break;
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
property_dsc++;
|
2009-12-26 20:26:56 +01:00
|
|
|
}
|
2010-01-02 23:52:30 +01:00
|
|
|
if (property_dsc == NULL || property_dsc->dbus_property == NULL) {
|
2009-12-26 20:26:56 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "no property handler for %s.%s on %s",
|
|
|
|
interface, property,
|
|
|
|
dbus_message_get_path(message));
|
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"No such property");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (os_strncmp(WPA_DBUS_PROPERTIES_GET, method,
|
2014-12-31 23:59:20 +01:00
|
|
|
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX) == 0) {
|
|
|
|
wpa_printf(MSG_MSGDUMP, "%s: Get(%s)", __func__, property);
|
2010-01-01 10:33:41 +01:00
|
|
|
return properties_get(message, property_dsc,
|
|
|
|
obj_dsc->user_data);
|
2014-12-31 23:59:20 +01:00
|
|
|
}
|
2009-12-26 20:26:56 +01:00
|
|
|
|
2014-12-31 23:59:20 +01:00
|
|
|
wpa_printf(MSG_MSGDUMP, "%s: Set(%s)", __func__, property);
|
2010-01-01 10:33:41 +01:00
|
|
|
return properties_set(message, property_dsc, obj_dsc->user_data);
|
2009-12-26 20:26:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DBusMessage * properties_handler(DBusMessage *message,
|
|
|
|
struct wpa_dbus_object_desc *obj_dsc)
|
|
|
|
{
|
|
|
|
DBusMessageIter iter;
|
|
|
|
char *interface;
|
|
|
|
const char *method;
|
|
|
|
|
|
|
|
method = dbus_message_get_member(message);
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
|
|
|
if (!os_strncmp(WPA_DBUS_PROPERTIES_GET, method,
|
|
|
|
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX) ||
|
|
|
|
!os_strncmp(WPA_DBUS_PROPERTIES_SET, method,
|
|
|
|
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX) ||
|
|
|
|
!os_strncmp(WPA_DBUS_PROPERTIES_GETALL, method,
|
|
|
|
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX)) {
|
|
|
|
/* First argument: interface name (DBUS_TYPE_STRING) */
|
2014-12-31 22:21:10 +01:00
|
|
|
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) {
|
2009-12-26 20:26:56 +01:00
|
|
|
return dbus_message_new_error(message,
|
|
|
|
DBUS_ERROR_INVALID_ARGS,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus_message_iter_get_basic(&iter, &interface);
|
|
|
|
|
|
|
|
if (!os_strncmp(WPA_DBUS_PROPERTIES_GETALL, method,
|
|
|
|
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX)) {
|
|
|
|
/* GetAll */
|
|
|
|
return properties_get_all(message, interface, obj_dsc);
|
|
|
|
}
|
|
|
|
/* Get or Set */
|
|
|
|
return properties_get_or_set(message, &iter, interface,
|
|
|
|
obj_dsc);
|
|
|
|
}
|
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_UNKNOWN_METHOD,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DBusMessage * msg_method_handler(DBusMessage *message,
|
|
|
|
struct wpa_dbus_object_desc *obj_dsc)
|
|
|
|
{
|
2010-01-02 23:52:30 +01:00
|
|
|
const struct wpa_dbus_method_desc *method_dsc = obj_dsc->methods;
|
2009-12-26 20:26:56 +01:00
|
|
|
const char *method;
|
|
|
|
const char *msg_interface;
|
|
|
|
|
|
|
|
method = dbus_message_get_member(message);
|
|
|
|
msg_interface = dbus_message_get_interface(message);
|
|
|
|
|
|
|
|
/* try match call to any registered method */
|
2010-01-02 23:52:30 +01:00
|
|
|
while (method_dsc && method_dsc->dbus_method) {
|
2009-12-26 20:26:56 +01:00
|
|
|
/* compare method names and interfaces */
|
|
|
|
if (!os_strncmp(method_dsc->dbus_method, method,
|
|
|
|
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX) &&
|
|
|
|
!os_strncmp(method_dsc->dbus_interface, msg_interface,
|
|
|
|
WPAS_DBUS_INTERFACE_MAX))
|
|
|
|
break;
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
method_dsc++;
|
2009-12-26 20:26:56 +01:00
|
|
|
}
|
2010-01-02 23:52:30 +01:00
|
|
|
if (method_dsc == NULL || method_dsc->dbus_method == NULL) {
|
2009-12-26 20:26:56 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "no method handler for %s.%s on %s",
|
|
|
|
msg_interface, method,
|
|
|
|
dbus_message_get_path(message));
|
|
|
|
return dbus_message_new_error(message,
|
|
|
|
DBUS_ERROR_UNKNOWN_METHOD, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_signature_correct(message, method_dsc)) {
|
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2014-12-31 22:21:10 +01:00
|
|
|
return method_dsc->method_handler(message, obj_dsc->user_data);
|
2009-12-26 20:26:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
/**
|
|
|
|
* message_handler - Handles incoming DBus messages
|
|
|
|
* @connection: DBus connection on which message was received
|
|
|
|
* @message: Received message
|
|
|
|
* @user_data: pointer to description of object to which message was sent
|
|
|
|
* Returns: Returns information whether message was handled or not
|
|
|
|
*
|
|
|
|
* Reads message interface and method name, then checks if they matches one
|
|
|
|
* of the special cases i.e. introspection call or properties get/getall/set
|
|
|
|
* methods and handles it. Else it iterates over registered methods list
|
|
|
|
* and tries to match method's name and interface to those read from message
|
2009-12-26 20:26:56 +01:00
|
|
|
* If appropriate method was found its handler function is called and
|
|
|
|
* response is sent. Otherwise, the DBUS_ERROR_UNKNOWN_METHOD error message
|
2009-11-09 22:51:59 +01:00
|
|
|
* will be sent.
|
|
|
|
*/
|
|
|
|
static DBusHandlerResult message_handler(DBusConnection *connection,
|
|
|
|
DBusMessage *message, void *user_data)
|
|
|
|
{
|
|
|
|
struct wpa_dbus_object_desc *obj_dsc = user_data;
|
|
|
|
const char *method;
|
|
|
|
const char *path;
|
|
|
|
const char *msg_interface;
|
2009-12-26 20:26:56 +01:00
|
|
|
DBusMessage *reply;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* get method, interface and path the message is addressed to */
|
|
|
|
method = dbus_message_get_member(message);
|
|
|
|
path = dbus_message_get_path(message);
|
|
|
|
msg_interface = dbus_message_get_interface(message);
|
|
|
|
if (!method || !path || !msg_interface)
|
2009-12-26 20:26:56 +01:00
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
2014-12-31 19:25:49 +01:00
|
|
|
wpa_printf(MSG_MSGDUMP, "dbus: %s.%s (%s) [%s]",
|
|
|
|
msg_interface, method, path,
|
|
|
|
dbus_message_get_signature(message));
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* if message is introspection method call */
|
|
|
|
if (!os_strncmp(WPA_DBUS_INTROSPECTION_METHOD, method,
|
|
|
|
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX) &&
|
|
|
|
!os_strncmp(WPA_DBUS_INTROSPECTION_INTERFACE, msg_interface,
|
2010-01-01 13:03:00 +01:00
|
|
|
WPAS_DBUS_INTERFACE_MAX)) {
|
|
|
|
#ifdef CONFIG_CTRL_IFACE_DBUS_INTRO
|
|
|
|
reply = wpa_dbus_introspect(message, obj_dsc);
|
|
|
|
#else /* CONFIG_CTRL_IFACE_DBUS_INTRO */
|
|
|
|
reply = dbus_message_new_error(
|
|
|
|
message, DBUS_ERROR_UNKNOWN_METHOD,
|
2014-12-31 22:21:10 +01:00
|
|
|
"wpa_supplicant was compiled without introspection support.");
|
2010-01-01 13:03:00 +01:00
|
|
|
#endif /* CONFIG_CTRL_IFACE_DBUS_INTRO */
|
|
|
|
} else if (!os_strncmp(WPA_DBUS_PROPERTIES_INTERFACE, msg_interface,
|
2009-12-26 20:26:56 +01:00
|
|
|
WPAS_DBUS_INTERFACE_MAX)) {
|
2009-11-09 22:51:59 +01:00
|
|
|
/* if message is properties method call */
|
2009-12-26 20:26:56 +01:00
|
|
|
reply = properties_handler(message, obj_dsc);
|
2009-11-09 22:51:59 +01:00
|
|
|
} else {
|
2009-12-26 20:26:56 +01:00
|
|
|
reply = msg_method_handler(message, obj_dsc);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
2009-12-26 20:26:56 +01:00
|
|
|
/* If handler succeed returning NULL, reply empty message */
|
|
|
|
if (!reply)
|
|
|
|
reply = dbus_message_new_method_return(message);
|
|
|
|
if (reply) {
|
|
|
|
if (!dbus_message_get_no_reply(message))
|
|
|
|
dbus_connection_send(connection, reply, NULL);
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
}
|
2010-01-04 16:15:57 +01:00
|
|
|
|
|
|
|
wpa_dbus_flush_all_changed_properties(connection);
|
|
|
|
|
2009-12-26 20:26:56 +01:00
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* free_dbus_object_desc - Frees object description data structure
|
|
|
|
* @connection: DBus connection
|
|
|
|
* @obj_dsc: Object description to free
|
|
|
|
*
|
|
|
|
* Frees each of properties, methods and signals description lists and
|
|
|
|
* the object description structure itself.
|
|
|
|
*/
|
|
|
|
void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc)
|
|
|
|
{
|
|
|
|
if (!obj_dsc)
|
|
|
|
return;
|
|
|
|
|
2010-01-01 10:33:41 +01:00
|
|
|
/* free handler's argument */
|
|
|
|
if (obj_dsc->user_data_free_func)
|
|
|
|
obj_dsc->user_data_free_func(obj_dsc->user_data);
|
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
os_free(obj_dsc->path);
|
|
|
|
os_free(obj_dsc->prop_changed_flags);
|
2009-11-09 22:51:59 +01:00
|
|
|
os_free(obj_dsc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void free_dbus_object_desc_cb(DBusConnection *connection, void *obj_dsc)
|
|
|
|
{
|
|
|
|
free_dbus_object_desc(obj_dsc);
|
|
|
|
}
|
|
|
|
|
2014-12-31 22:21:10 +01:00
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
/**
|
|
|
|
* wpa_dbus_ctrl_iface_init - Initialize dbus control interface
|
|
|
|
* @application_data: Pointer to application specific data structure
|
|
|
|
* @dbus_path: DBus path to interface object
|
|
|
|
* @dbus_service: DBus service name to register with
|
|
|
|
* @messageHandler: a pointer to function which will handle dbus messages
|
|
|
|
* coming on interface
|
2009-12-30 23:15:56 +01:00
|
|
|
* Returns: 0 on success, -1 on failure
|
2009-11-09 22:51:59 +01:00
|
|
|
*
|
|
|
|
* Initialize the dbus control interface and start receiving commands from
|
|
|
|
* external programs over the bus.
|
|
|
|
*/
|
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
|
|
|
{
|
|
|
|
DBusError error;
|
|
|
|
int ret = -1;
|
|
|
|
DBusObjectPathVTable wpa_vtable = {
|
|
|
|
&free_dbus_object_desc_cb, &message_handler,
|
|
|
|
NULL, NULL, NULL, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
obj_desc->connection = iface->con;
|
2010-01-04 16:15:57 +01:00
|
|
|
obj_desc->path = os_strdup(dbus_path);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Register the message handler for the global dbus interface */
|
2014-12-31 22:21:10 +01:00
|
|
|
if (!dbus_connection_register_object_path(iface->con, dbus_path,
|
|
|
|
&wpa_vtable, obj_desc)) {
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: Could not set up message handler");
|
2009-12-30 23:15:56 +01:00
|
|
|
return -1;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Register our service with the message bus */
|
|
|
|
dbus_error_init(&error);
|
2014-12-31 22:21:10 +01:00
|
|
|
switch (dbus_bus_request_name(iface->con, dbus_service, 0, &error)) {
|
2009-11-09 22:51:59 +01:00
|
|
|
case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
case DBUS_REQUEST_NAME_REPLY_EXISTS:
|
|
|
|
case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
|
|
|
|
case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: Could not request service name: already registered");
|
2009-11-09 22:51:59 +01:00
|
|
|
break;
|
|
|
|
default:
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: Could not request service name: %s %s",
|
|
|
|
error.name, error.message);
|
2009-11-09 22:51:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
dbus_error_free(&error);
|
|
|
|
|
|
|
|
if (ret != 0)
|
2009-12-30 23:15:56 +01:00
|
|
|
return -1;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "Providing DBus service '%s'.", dbus_service);
|
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
return 0;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_dbus_register_object_per_iface - Register a new object with dbus
|
|
|
|
* @ctrl_iface: pointer to dbus private data
|
|
|
|
* @path: DBus path to object
|
|
|
|
* @ifname: interface name
|
|
|
|
* @obj_desc: description 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.
|
|
|
|
*/
|
2014-12-31 22:21:10 +01:00
|
|
|
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)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
DBusConnection *con;
|
2011-02-02 16:03:32 +01:00
|
|
|
DBusError error;
|
2009-11-09 22:51:59 +01:00
|
|
|
DBusObjectPathVTable vtable = {
|
|
|
|
&free_dbus_object_desc_cb, &message_handler,
|
|
|
|
NULL, NULL, NULL, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (ctrl_iface == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
con = ctrl_iface->con;
|
|
|
|
obj_desc->connection = con;
|
2010-01-04 16:15:57 +01:00
|
|
|
obj_desc->path = os_strdup(path);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2011-02-02 16:03:32 +01:00
|
|
|
dbus_error_init(&error);
|
2009-11-09 22:51:59 +01:00
|
|
|
/* Register the message handler for the interface functions */
|
2011-02-02 16:03:32 +01:00
|
|
|
if (!dbus_connection_try_register_object_path(con, path, &vtable,
|
|
|
|
obj_desc, &error)) {
|
2014-12-31 22:21:10 +01:00
|
|
|
if (os_strcmp(error.name, DBUS_ERROR_OBJECT_PATH_IN_USE) == 0) {
|
2011-02-02 16:03:32 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: %s", error.message);
|
|
|
|
} else {
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: Could not set up message handler for interface %s object %s (error: %s message: %s)",
|
|
|
|
ifname, path, error.name, error.message);
|
2011-02-02 16:03:32 +01:00
|
|
|
}
|
|
|
|
dbus_error_free(&error);
|
2009-11-09 22:51:59 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-02-02 16:03:32 +01:00
|
|
|
dbus_error_free(&error);
|
2009-11-09 22:51:59 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
static void flush_object_timeout_handler(void *eloop_ctx, void *timeout_ctx);
|
|
|
|
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
/**
|
|
|
|
* wpa_dbus_unregister_object_per_iface - Unregisters DBus object
|
|
|
|
* @ctrl_iface: Pointer to dbus private data
|
|
|
|
* @path: DBus path to object which will be unregistered
|
|
|
|
* Returns: Zero on success and -1 on failure
|
|
|
|
*
|
|
|
|
* Unregisters DBus object given by its path
|
|
|
|
*/
|
|
|
|
int wpa_dbus_unregister_object_per_iface(
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface, const char *path)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
DBusConnection *con = ctrl_iface->con;
|
2010-01-06 10:50:43 +01:00
|
|
|
struct wpa_dbus_object_desc *obj_desc = NULL;
|
2010-01-04 16:15:57 +01:00
|
|
|
|
2010-01-06 10:50:43 +01:00
|
|
|
dbus_connection_get_object_path_data(con, path, (void **) &obj_desc);
|
|
|
|
if (!obj_desc) {
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: %s: Could not obtain object's private data: %s",
|
|
|
|
__func__, path);
|
2013-08-31 15:46:24 +02:00
|
|
|
return 0;
|
2010-01-06 10:50:43 +01:00
|
|
|
}
|
2010-01-04 16:15:57 +01:00
|
|
|
|
2013-08-31 15:46:24 +02:00
|
|
|
eloop_cancel_timeout(flush_object_timeout_handler, con, obj_desc);
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
if (!dbus_connection_unregister_object_path(con, path))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
static dbus_bool_t put_changed_properties(
|
|
|
|
const struct wpa_dbus_object_desc *obj_dsc, const char *interface,
|
2011-10-29 18:23:42 +02:00
|
|
|
DBusMessageIter *dict_iter, int clear_changed)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusMessageIter entry_iter;
|
2010-01-04 16:15:57 +01:00
|
|
|
const struct wpa_dbus_property_desc *dsc;
|
|
|
|
int i;
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusError error;
|
2010-01-04 16:15:57 +01:00
|
|
|
|
|
|
|
for (dsc = obj_dsc->properties, i = 0; dsc && dsc->dbus_property;
|
|
|
|
dsc++, i++) {
|
|
|
|
if (obj_dsc->prop_changed_flags == NULL ||
|
|
|
|
!obj_dsc->prop_changed_flags[i])
|
|
|
|
continue;
|
|
|
|
if (os_strcmp(dsc->dbus_interface, interface) != 0)
|
|
|
|
continue;
|
2011-10-29 18:23:42 +02:00
|
|
|
if (clear_changed)
|
|
|
|
obj_dsc->prop_changed_flags[i] = 0;
|
2010-01-04 16:15:57 +01:00
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
if (!dbus_message_iter_open_container(dict_iter,
|
2010-01-04 16:15:57 +01:00
|
|
|
DBUS_TYPE_DICT_ENTRY,
|
2014-12-31 12:57:48 +01:00
|
|
|
NULL, &entry_iter) ||
|
|
|
|
!dbus_message_iter_append_basic(&entry_iter,
|
2010-01-04 16:15:57 +01:00
|
|
|
DBUS_TYPE_STRING,
|
|
|
|
&dsc->dbus_property))
|
2011-07-29 20:25:39 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
dbus_error_init(&error);
|
2015-10-13 18:45:33 +02:00
|
|
|
if (!dsc->getter(dsc, &entry_iter, &error, obj_dsc->user_data))
|
|
|
|
{
|
2014-12-31 22:21:10 +01:00
|
|
|
if (dbus_error_is_set(&error)) {
|
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: %s: Cannot get new value of property %s: (%s) %s",
|
|
|
|
__func__, dsc->dbus_property,
|
|
|
|
error.name, error.message);
|
2011-07-29 20:25:39 +02:00
|
|
|
} else {
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: %s: Cannot get new value of property %s",
|
2011-07-29 20:25:39 +02:00
|
|
|
__func__, dsc->dbus_property);
|
|
|
|
}
|
|
|
|
dbus_error_free(&error);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
if (!dbus_message_iter_close_container(dict_iter, &entry_iter))
|
2011-07-29 20:25:39 +02:00
|
|
|
return FALSE;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
return TRUE;
|
2010-01-04 16:15:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-29 18:23:42 +02:00
|
|
|
static void do_send_prop_changed_signal(
|
|
|
|
DBusConnection *con, const char *path, const char *interface,
|
|
|
|
const struct wpa_dbus_object_desc *obj_dsc)
|
|
|
|
{
|
|
|
|
DBusMessage *msg;
|
|
|
|
DBusMessageIter signal_iter, dict_iter;
|
|
|
|
|
|
|
|
msg = dbus_message_new_signal(path, DBUS_INTERFACE_PROPERTIES,
|
|
|
|
"PropertiesChanged");
|
|
|
|
if (msg == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dbus_message_iter_init_append(msg, &signal_iter);
|
|
|
|
|
|
|
|
if (!dbus_message_iter_append_basic(&signal_iter, DBUS_TYPE_STRING,
|
2014-12-31 12:57:48 +01:00
|
|
|
&interface) ||
|
|
|
|
/* Changed properties dict */
|
|
|
|
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
|
|
|
"{sv}", &dict_iter) ||
|
|
|
|
!put_changed_properties(obj_dsc, interface, &dict_iter, 0) ||
|
|
|
|
!dbus_message_iter_close_container(&signal_iter, &dict_iter) ||
|
|
|
|
/* Invalidated properties array (empty) */
|
|
|
|
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
|
|
|
"s", &dict_iter) ||
|
2014-12-31 22:21:10 +01:00
|
|
|
!dbus_message_iter_close_container(&signal_iter, &dict_iter)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal",
|
|
|
|
__func__);
|
|
|
|
} else {
|
|
|
|
dbus_connection_send(con, msg, NULL);
|
|
|
|
}
|
2011-10-29 18:23:42 +02:00
|
|
|
|
|
|
|
dbus_message_unref(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_send_deprecated_prop_changed_signal(
|
2010-01-04 16:15:57 +01:00
|
|
|
DBusConnection *con, const char *path, const char *interface,
|
|
|
|
const struct wpa_dbus_object_desc *obj_dsc)
|
|
|
|
{
|
|
|
|
DBusMessage *msg;
|
|
|
|
DBusMessageIter signal_iter, dict_iter;
|
|
|
|
|
|
|
|
msg = dbus_message_new_signal(path, interface, "PropertiesChanged");
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_iter_init_append(msg, &signal_iter);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
2014-12-31 12:57:48 +01:00
|
|
|
"{sv}", &dict_iter) ||
|
|
|
|
!put_changed_properties(obj_dsc, interface, &dict_iter, 1) ||
|
2014-12-31 22:21:10 +01:00
|
|
|
!dbus_message_iter_close_container(&signal_iter, &dict_iter)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal",
|
|
|
|
__func__);
|
|
|
|
} else {
|
|
|
|
dbus_connection_send(con, msg, NULL);
|
|
|
|
}
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
2010-01-01 11:47:59 +01:00
|
|
|
|
|
|
|
|
2011-10-29 18:23:42 +02:00
|
|
|
static void send_prop_changed_signal(
|
|
|
|
DBusConnection *con, const char *path, const char *interface,
|
|
|
|
const struct wpa_dbus_object_desc *obj_dsc)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* First, send property change notification on the standardized
|
|
|
|
* org.freedesktop.DBus.Properties interface. This call will not
|
|
|
|
* clear the property change bits, so that they are preserved for
|
|
|
|
* the call that follows.
|
|
|
|
*/
|
|
|
|
do_send_prop_changed_signal(con, path, interface, obj_dsc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now send PropertiesChanged on our own interface for backwards
|
|
|
|
* compatibility. This is deprecated and will be removed in a future
|
|
|
|
* release.
|
|
|
|
*/
|
|
|
|
do_send_deprecated_prop_changed_signal(con, path, interface, obj_dsc);
|
|
|
|
|
|
|
|
/* Property change bits have now been cleared. */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
static void flush_object_timeout_handler(void *eloop_ctx, void *timeout_ctx)
|
|
|
|
{
|
|
|
|
DBusConnection *con = eloop_ctx;
|
2010-01-06 10:50:43 +01:00
|
|
|
struct wpa_dbus_object_desc *obj_desc = timeout_ctx;
|
2010-01-04 16:15:57 +01:00
|
|
|
|
2019-07-31 03:09:33 +02:00
|
|
|
wpa_printf(MSG_MSGDUMP,
|
2014-12-31 22:21:10 +01:00
|
|
|
"dbus: %s: Timeout - sending changed properties of object %s",
|
|
|
|
__func__, obj_desc->path);
|
2010-01-06 10:50:43 +01:00
|
|
|
wpa_dbus_flush_object_changed_properties(con, obj_desc->path);
|
2010-01-04 16:15:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void recursive_flush_changed_properties(DBusConnection *con,
|
|
|
|
const char *path)
|
|
|
|
{
|
|
|
|
char **objects = NULL;
|
|
|
|
char subobj_path[WPAS_DBUS_OBJECT_PATH_MAX];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
wpa_dbus_flush_object_changed_properties(con, path);
|
|
|
|
|
|
|
|
if (!dbus_connection_list_registered(con, path, &objects))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
for (i = 0; objects[i]; i++) {
|
|
|
|
os_snprintf(subobj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s/%s", path, objects[i]);
|
|
|
|
recursive_flush_changed_properties(con, subobj_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
dbus_free_string_array(objects);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_dbus_flush_all_changed_properties - Send all PropertiesChanged signals
|
|
|
|
* @con: DBus connection
|
|
|
|
*
|
|
|
|
* Traverses through all registered objects and sends PropertiesChanged for
|
|
|
|
* each properties.
|
|
|
|
*/
|
|
|
|
void wpa_dbus_flush_all_changed_properties(DBusConnection *con)
|
|
|
|
{
|
|
|
|
recursive_flush_changed_properties(con, WPAS_DBUS_NEW_PATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_dbus_flush_object_changed_properties - Send PropertiesChanged for object
|
|
|
|
* @con: DBus connection
|
|
|
|
* @path: path 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.
|
|
|
|
*/
|
|
|
|
void wpa_dbus_flush_object_changed_properties(DBusConnection *con,
|
|
|
|
const char *path)
|
|
|
|
{
|
|
|
|
struct wpa_dbus_object_desc *obj_desc = NULL;
|
|
|
|
const struct wpa_dbus_property_desc *dsc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dbus_connection_get_object_path_data(con, path, (void **) &obj_desc);
|
|
|
|
if (!obj_desc)
|
|
|
|
return;
|
2010-01-06 10:50:43 +01:00
|
|
|
eloop_cancel_timeout(flush_object_timeout_handler, con, obj_desc);
|
2010-01-04 16:15:57 +01:00
|
|
|
|
|
|
|
for (dsc = obj_desc->properties, i = 0; dsc && dsc->dbus_property;
|
|
|
|
dsc++, i++) {
|
|
|
|
if (obj_desc->prop_changed_flags == NULL ||
|
|
|
|
!obj_desc->prop_changed_flags[i])
|
|
|
|
continue;
|
|
|
|
send_prop_changed_signal(con, path, dsc->dbus_interface,
|
|
|
|
obj_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define WPA_DBUS_SEND_PROP_CHANGED_TIMEOUT 5000
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_dbus_mark_property_changed - Mark a property as changed and
|
|
|
|
* @iface: dbus priv struct
|
|
|
|
* @path: path to DBus object which property has changed
|
|
|
|
* @interface: interface containing changed property
|
|
|
|
* @property: property 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.
|
|
|
|
*/
|
|
|
|
void wpa_dbus_mark_property_changed(struct wpas_dbus_priv *iface,
|
|
|
|
const char *path, const char *interface,
|
|
|
|
const char *property)
|
|
|
|
{
|
|
|
|
struct wpa_dbus_object_desc *obj_desc = NULL;
|
|
|
|
const struct wpa_dbus_property_desc *dsc;
|
|
|
|
int i = 0;
|
|
|
|
|
2010-01-06 11:14:35 +01:00
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
dbus_connection_get_object_path_data(iface->con, path,
|
|
|
|
(void **) &obj_desc);
|
|
|
|
if (!obj_desc) {
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: wpa_dbus_property_changed: could not obtain object's private data: %s",
|
|
|
|
path);
|
2010-01-04 16:15:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (dsc = obj_desc->properties; dsc && dsc->dbus_property; dsc++, i++)
|
|
|
|
if (os_strcmp(property, dsc->dbus_property) == 0 &&
|
|
|
|
os_strcmp(interface, dsc->dbus_interface) == 0) {
|
|
|
|
if (obj_desc->prop_changed_flags)
|
|
|
|
obj_desc->prop_changed_flags[i] = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dsc || !dsc->dbus_property) {
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: wpa_dbus_property_changed: no property %s in object %s",
|
|
|
|
property, path);
|
2010-01-04 16:15:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eloop_is_timeout_registered(flush_object_timeout_handler,
|
2014-12-31 22:20:01 +01:00
|
|
|
iface->con, obj_desc)) {
|
2010-01-04 16:15:57 +01:00
|
|
|
eloop_register_timeout(0, WPA_DBUS_SEND_PROP_CHANGED_TIMEOUT,
|
|
|
|
flush_object_timeout_handler,
|
2010-01-06 10:50:43 +01:00
|
|
|
iface->con, obj_desc);
|
2010-01-04 16:15:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-01 11:47:59 +01:00
|
|
|
/**
|
|
|
|
* wpa_dbus_get_object_properties - Put object's properties into dictionary
|
|
|
|
* @iface: dbus priv struct
|
|
|
|
* @path: path to DBus object which properties will be obtained
|
|
|
|
* @interface: interface name which properties will be obtained
|
2011-07-29 20:25:39 +02:00
|
|
|
* @iter: DBus message iter at which to append property dictionary.
|
2010-01-01 11:47:59 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
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)
|
2010-01-01 11:47:59 +01:00
|
|
|
{
|
|
|
|
struct wpa_dbus_object_desc *obj_desc = NULL;
|
2011-07-29 20:25:39 +02:00
|
|
|
DBusMessageIter dict_iter;
|
|
|
|
DBusError error;
|
2010-01-01 11:47:59 +01:00
|
|
|
|
|
|
|
dbus_connection_get_object_path_data(iface->con, path,
|
|
|
|
(void **) &obj_desc);
|
|
|
|
if (!obj_desc) {
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: %s: could not obtain object's private data: %s",
|
|
|
|
__func__, path);
|
2011-07-29 20:25:39 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wpa_dbus_dict_open_write(iter, &dict_iter)) {
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: %s: failed to open message dict",
|
|
|
|
__func__);
|
|
|
|
return FALSE;
|
2010-01-01 11:47:59 +01:00
|
|
|
}
|
|
|
|
|
2011-07-29 20:25:39 +02:00
|
|
|
dbus_error_init(&error);
|
|
|
|
if (!fill_dict_with_properties(&dict_iter, obj_desc->properties,
|
|
|
|
interface, obj_desc->user_data,
|
|
|
|
&error)) {
|
2014-12-31 22:21:10 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"dbus: %s: failed to get object properties: (%s) %s",
|
|
|
|
__func__,
|
|
|
|
dbus_error_is_set(&error) ? error.name : "none",
|
|
|
|
dbus_error_is_set(&error) ? error.message : "none");
|
2011-07-29 20:25:39 +02:00
|
|
|
dbus_error_free(&error);
|
2019-05-08 21:06:46 +02:00
|
|
|
wpa_dbus_dict_close_write(iter, &dict_iter);
|
2011-07-29 20:25:39 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wpa_dbus_dict_close_write(iter, &dict_iter);
|
2010-01-01 11:47:59 +01:00
|
|
|
}
|
2011-06-12 23:41:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_new_decompose_object_path - Decompose an interface object path into parts
|
|
|
|
* @path: The dbus object path
|
2015-01-01 10:42:32 +01:00
|
|
|
* @sep: Separating 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
|
2011-06-12 23:41:41 +02:00
|
|
|
*
|
2015-01-01 10:42:32 +01:00
|
|
|
* 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".
|
2011-06-12 23:41:41 +02:00
|
|
|
*/
|
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
|
|
|
{
|
|
|
|
const unsigned int dev_path_prefix_len =
|
|
|
|
os_strlen(WPAS_DBUS_NEW_PATH_INTERFACES "/");
|
|
|
|
char *obj_path_only;
|
2015-01-01 10:42:32 +01:00
|
|
|
char *pos;
|
|
|
|
size_t sep_len;
|
2011-06-12 23:41:41 +02:00
|
|
|
|
2015-01-01 10:42:32 +01:00
|
|
|
*item = NULL;
|
|
|
|
|
|
|
|
/* Verify that this starts with our interface prefix */
|
|
|
|
if (os_strncmp(path, WPAS_DBUS_NEW_PATH_INTERFACES "/",
|
|
|
|
dev_path_prefix_len) != 0)
|
|
|
|
return NULL; /* not our path */
|
2011-06-12 23:41:41 +02:00
|
|
|
|
|
|
|
/* Ensure there's something at the end of the path */
|
|
|
|
if ((path + dev_path_prefix_len)[0] == '\0')
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
obj_path_only = os_strdup(path);
|
|
|
|
if (obj_path_only == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2015-01-01 10:42:32 +01:00
|
|
|
pos = obj_path_only + dev_path_prefix_len;
|
|
|
|
pos = os_strchr(pos, '/');
|
|
|
|
if (pos == NULL)
|
|
|
|
return obj_path_only; /* no next item on the path */
|
2011-06-12 23:41:41 +02:00
|
|
|
|
2015-01-01 10:42:32 +01:00
|
|
|
/* Separate network interface prefix from the path */
|
|
|
|
*pos++ = '\0';
|
|
|
|
|
|
|
|
sep_len = os_strlen(sep);
|
|
|
|
if (os_strncmp(pos, sep, sep_len) != 0 || pos[sep_len] != '/')
|
|
|
|
return obj_path_only; /* no match */
|
2011-06-12 23:41:41 +02:00
|
|
|
|
2015-01-01 10:42:32 +01:00
|
|
|
/* return a pointer to the requested item */
|
|
|
|
*item = pos + sep_len + 1;
|
2011-06-12 23:41:41 +02:00
|
|
|
return obj_path_only;
|
|
|
|
}
|
2011-07-29 20:25:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_reply_new_from_error - Create a new D-Bus error message from a
|
|
|
|
* dbus error structure
|
|
|
|
* @message: The original request message for which the error is a reply
|
|
|
|
* @error: The error containing a name and a descriptive error cause
|
|
|
|
* @fallback_name: A generic error name if @error was not set
|
|
|
|
* @fallback_string: A 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.
|
|
|
|
*/
|
|
|
|
DBusMessage * wpas_dbus_reply_new_from_error(DBusMessage *message,
|
|
|
|
DBusError *error,
|
|
|
|
const char *fallback_name,
|
|
|
|
const char *fallback_string)
|
|
|
|
{
|
|
|
|
if (error && error->name && error->message) {
|
|
|
|
return dbus_message_new_error(message, error->name,
|
|
|
|
error->message);
|
|
|
|
}
|
|
|
|
if (fallback_name && fallback_string) {
|
|
|
|
return dbus_message_new_error(message, fallback_name,
|
|
|
|
fallback_string);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-12-01 00:33:10 +01:00
|
|
|
|
|
|
|
|
2023-07-19 19:29:15 +02:00
|
|
|
static double guard_interval_to_double(enum guard_interval value)
|
|
|
|
{
|
|
|
|
switch (value) {
|
|
|
|
case GUARD_INTERVAL_0_4:
|
|
|
|
return 0.4;
|
|
|
|
case GUARD_INTERVAL_0_8:
|
|
|
|
return 0.8;
|
|
|
|
case GUARD_INTERVAL_1_6:
|
|
|
|
return 1.6;
|
|
|
|
case GUARD_INTERVAL_3_2:
|
|
|
|
return 3.2;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-01 00:33:10 +01:00
|
|
|
/**
|
|
|
|
* wpas_dbus_new_from_signal_information - Adds a wpa_signal_info
|
|
|
|
* to a DBusMessage.
|
|
|
|
* @msg: Pointer to message to append fields to
|
|
|
|
* @si: Pointer to wpa_signal_info to add to the message
|
|
|
|
* Returns: 0 on success, otherwise, an errorcode
|
|
|
|
*
|
|
|
|
* Adds all the pertinent fields from a wpa_signal_info to a DBusMessage.
|
|
|
|
* The same logic is useful in both responding to signal_poll calls, and
|
|
|
|
* sending signal_change signals.
|
|
|
|
*/
|
|
|
|
int wpas_dbus_new_from_signal_information(DBusMessageIter *iter,
|
|
|
|
struct wpa_signal_info *si)
|
|
|
|
{
|
|
|
|
DBusMessageIter iter_dict, variant_iter;
|
|
|
|
|
|
|
|
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
|
|
|
|
"a{sv}", &variant_iter) ||
|
|
|
|
!wpa_dbus_dict_open_write(&variant_iter, &iter_dict) ||
|
|
|
|
!wpa_dbus_dict_append_int32(&iter_dict, "rssi",
|
|
|
|
si->data.signal) ||
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "linkspeed",
|
|
|
|
si->data.current_tx_rate / 1000) ||
|
|
|
|
!wpa_dbus_dict_append_int32(&iter_dict, "noise",
|
|
|
|
si->current_noise) ||
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "frequency",
|
|
|
|
si->frequency) ||
|
|
|
|
(si->chanwidth != CHAN_WIDTH_UNKNOWN &&
|
|
|
|
!wpa_dbus_dict_append_string(
|
|
|
|
&iter_dict, "width",
|
|
|
|
channel_width_to_string(si->chanwidth))) ||
|
|
|
|
(si->center_frq1 > 0 && si->center_frq2 > 0 &&
|
|
|
|
(!wpa_dbus_dict_append_int32(&iter_dict, "center-frq1",
|
|
|
|
si->center_frq1) ||
|
|
|
|
!wpa_dbus_dict_append_int32(&iter_dict, "center-frq2",
|
|
|
|
si->center_frq2))) ||
|
|
|
|
(si->data.avg_signal &&
|
|
|
|
!wpa_dbus_dict_append_int32(&iter_dict, "avg-rssi",
|
|
|
|
si->data.avg_signal)) ||
|
|
|
|
(si->data.rx_bytes &&
|
|
|
|
!wpa_dbus_dict_append_uint64(&iter_dict, "rx-bytes",
|
|
|
|
si->data.rx_bytes)) ||
|
|
|
|
(si->data.tx_bytes &&
|
|
|
|
!wpa_dbus_dict_append_uint64(&iter_dict, "tx-bytes",
|
|
|
|
si->data.tx_bytes)) ||
|
|
|
|
(si->data.rx_packets &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-packets",
|
|
|
|
si->data.rx_packets)) ||
|
|
|
|
(si->data.tx_packets &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-packets",
|
|
|
|
si->data.tx_packets)) ||
|
|
|
|
(si->data.beacons_count &&
|
|
|
|
!wpa_dbus_dict_append_uint64(&iter_dict, "beacons",
|
|
|
|
si->data.beacons_count)) ||
|
|
|
|
(si->data.current_rx_rate &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "linkrxspeed",
|
|
|
|
si->data.current_rx_rate)) ||
|
|
|
|
(si->data.current_rx_rate &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "linktxspeed",
|
|
|
|
si->data.current_tx_rate)) ||
|
2022-12-22 21:54:41 +01:00
|
|
|
(si->data.inactive_msec &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "inactive-time",
|
|
|
|
si->data.inactive_msec)) ||
|
2022-12-01 00:33:10 +01:00
|
|
|
(si->data.tx_retry_failed &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "retries-failed",
|
|
|
|
si->data.tx_retry_failed)) ||
|
|
|
|
(si->data.tx_retry_count &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "retries",
|
|
|
|
si->data.tx_retry_count)) ||
|
|
|
|
(si->data.last_ack_rssi &&
|
|
|
|
!wpa_dbus_dict_append_int32(&iter_dict, "last-ack-rssi",
|
|
|
|
si->data.last_ack_rssi)) ||
|
|
|
|
(si->data.fcs_error_count &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "fcs-errors",
|
|
|
|
si->data.fcs_error_count)) ||
|
|
|
|
(si->data.beacon_loss_count &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "beacon-losses",
|
|
|
|
si->data.beacon_loss_count)) ||
|
|
|
|
(si->data.expected_throughput &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "expected-throughput",
|
|
|
|
si->data.expected_throughput)) ||
|
|
|
|
(si->data.rx_drop_misc &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-drop-misc",
|
|
|
|
si->data.rx_drop_misc)) ||
|
|
|
|
(si->data.rx_mpdus &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-mpdus",
|
|
|
|
si->data.rx_mpdus)) ||
|
|
|
|
(si->data.rx_hemcs &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-he-mcs",
|
|
|
|
si->data.rx_hemcs)) ||
|
|
|
|
(si->data.tx_hemcs &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-he-mcs",
|
|
|
|
si->data.tx_hemcs)) ||
|
|
|
|
(si->data.rx_vhtmcs &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-vht-mcs",
|
|
|
|
si->data.rx_vhtmcs)) ||
|
|
|
|
(si->data.tx_vhtmcs &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-vht-mcs",
|
|
|
|
si->data.tx_vhtmcs)) ||
|
|
|
|
(si->data.rx_mcs &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-mcs",
|
|
|
|
si->data.rx_mcs)) ||
|
|
|
|
(si->data.tx_mcs &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-mcs",
|
|
|
|
si->data.tx_mcs)) ||
|
|
|
|
(si->data.rx_he_nss &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-he-nss",
|
|
|
|
si->data.rx_he_nss)) ||
|
|
|
|
(si->data.tx_he_nss &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-he-nss",
|
|
|
|
si->data.tx_he_nss)) ||
|
|
|
|
(si->data.rx_vht_nss &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "rx-vht-nss",
|
|
|
|
si->data.rx_vht_nss)) ||
|
|
|
|
(si->data.tx_vht_nss &&
|
|
|
|
!wpa_dbus_dict_append_uint32(&iter_dict, "tx-vht-nss",
|
|
|
|
si->data.tx_vht_nss)) ||
|
|
|
|
(si->data.avg_beacon_signal &&
|
|
|
|
!wpa_dbus_dict_append_int32(&iter_dict, "avg-beacon-rssi",
|
|
|
|
si->data.avg_beacon_signal)) ||
|
|
|
|
(si->data.avg_ack_signal &&
|
|
|
|
!wpa_dbus_dict_append_int32(&iter_dict, "avg-ack-rssi",
|
|
|
|
si->data.avg_ack_signal)) ||
|
2023-07-19 19:29:15 +02:00
|
|
|
(si->data.rx_guard_interval &&
|
|
|
|
!wpa_dbus_dict_append_double(
|
|
|
|
&iter_dict, "rx-guard-interval",
|
|
|
|
guard_interval_to_double(si->data.rx_guard_interval))) ||
|
|
|
|
(si->data.tx_guard_interval &&
|
|
|
|
!wpa_dbus_dict_append_double(
|
|
|
|
&iter_dict, "tx-guard-interval",
|
|
|
|
guard_interval_to_double(si->data.tx_guard_interval))) ||
|
|
|
|
((si->data.flags & STA_DRV_DATA_RX_HE_DCM) &&
|
|
|
|
!wpa_dbus_dict_append_bool(&iter_dict, "rx-dcm",
|
|
|
|
si->data.rx_dcm)) ||
|
|
|
|
((si->data.flags & STA_DRV_DATA_TX_HE_DCM) &&
|
|
|
|
!wpa_dbus_dict_append_bool(&iter_dict, "tx-dcm",
|
|
|
|
si->data.tx_dcm)) ||
|
2022-12-01 00:33:10 +01:00
|
|
|
!wpa_dbus_dict_close_write(&variant_iter, &iter_dict) ||
|
|
|
|
!dbus_message_iter_close_container(iter, &variant_iter))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|