dbus: Divide DebugParams property to three separate properties

This commit is contained in:
Witold Sowa 2010-01-01 13:00:22 +02:00 committed by Jouni Malinen
parent b7e8feec68
commit db9133acb2
8 changed files with 225 additions and 187 deletions

View file

@ -98,8 +98,18 @@ registered in the bus with fi.w1.wpa_supplicant1 name.
<ul>
<li>
<h3>DebugParams - (ibb) - (read/write)</h3>
<p>A structure describing debugging properties. The structure elements are (in order): debug level (i), show timestamps (b), show keys (b).</p>
<h3>DebugLevel - y - (read/write)</h3>
<p>Global %wpa_supplicant debuging level. Possible values are 0, 1, 2, 3 and 4</p>
</li>
<li>
<h3>DebugTimestamp - b - (read/write)</h3>
<p>Global %wpa_supplicant debuging parameter. Determines if timestamps are shown in debug logs.</p>
</li>
<li>
<h3>DebugShowKeys - b - (read/write)</h3>
<p>Global %wpa_supplicant debuging parameter. Determines if secrets are shown in debug logs.</p>
</li>
<li>

View file

@ -964,20 +964,53 @@ static void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
/**
* wpas_dbus_signal_debug_params_changed - Signals change of debug params
* wpas_dbus_signal_debug_level_changed - Signals change of debug param
* @global: wpa_global structure
*
* Sends ProertyChanged signals informing that debug params has changed.
* Sends ProertyChanged signals informing that debug level has changed.
*/
static void wpas_dbus_signal_debug_params_changed(struct wpa_global *global)
static void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
{
wpa_dbus_signal_property_changed(global->dbus,
(WPADBusPropertyAccessor)
wpas_dbus_getter_debug_params,
wpas_dbus_getter_debug_level,
global, WPAS_DBUS_NEW_PATH,
WPAS_DBUS_NEW_INTERFACE,
"DebugParams");
"DebugLevel");
}
/**
* wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
* @global: wpa_global structure
*
* Sends ProertyChanged signals informing that debug timestamp has changed.
*/
static void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
{
wpa_dbus_signal_property_changed(global->dbus,
(WPADBusPropertyAccessor)
wpas_dbus_getter_debug_timestamp,
global, WPAS_DBUS_NEW_PATH,
WPAS_DBUS_NEW_INTERFACE,
"DebugTimestamp");
}
/**
* wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
* @global: wpa_global structure
*
* Sends ProertyChanged signals informing that debug show_keys has changed.
*/
static void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
{
wpa_dbus_signal_property_changed(global->dbus,
(WPADBusPropertyAccessor)
wpas_dbus_getter_debug_show_keys,
global, WPAS_DBUS_NEW_PATH,
WPAS_DBUS_NEW_INTERFACE,
"DebugShowKeys");
}
@ -1066,9 +1099,19 @@ static const struct wpas_dbus_method wpas_dbus_global_methods[] = {
};
static const struct wpas_dbus_property wpas_dbus_global_properties[] = {
{ "DebugParams", WPAS_DBUS_NEW_INTERFACE, "(ibb)",
(WPADBusPropertyAccessor) &wpas_dbus_getter_debug_params,
(WPADBusPropertyAccessor) &wpas_dbus_setter_debug_params,
{ "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "y",
(WPADBusPropertyAccessor) wpas_dbus_getter_debug_level,
(WPADBusPropertyAccessor) wpas_dbus_setter_debug_level,
RW
},
{ "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
(WPADBusPropertyAccessor) wpas_dbus_getter_debug_timestamp,
(WPADBusPropertyAccessor) wpas_dbus_setter_debug_timestamp,
RW
},
{ "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
(WPADBusPropertyAccessor) wpas_dbus_getter_debug_show_keys,
(WPADBusPropertyAccessor) wpas_dbus_setter_debug_show_keys,
RW
},
{ "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
@ -1828,7 +1871,12 @@ static struct wpas_dbus_callbacks callbacks =
.unregister_bss = wpas_dbus_unregister_bss,
.signal_prop_changed = wpas_dbus_signal_prop_changed,
.signal_debug_params_changed = wpas_dbus_signal_debug_params_changed,
.signal_debug_level_changed = wpas_dbus_signal_debug_level_changed,
.signal_debug_timestamp_changed =
wpas_dbus_signal_debug_timestamp_changed,
.signal_debug_show_keys_changed =
wpas_dbus_signal_debug_show_keys_changed,
#ifdef CONFIG_WPS
.signal_wps_event_success = wpas_dbus_signal_wps_event_success,

View file

@ -66,7 +66,10 @@ struct wpas_dbus_callbacks {
void (*signal_prop_changed)(struct wpa_supplicant *wpa_s,
enum wpas_dbus_prop property);
void (*signal_debug_params_changed)(struct wpa_global *global);
void (*signal_debug_level_changed)(struct wpa_global *global);
void (*signal_debug_timestamp_changed)(struct wpa_global *global);
void (*signal_debug_show_keys_changed)(struct wpa_global *global);
void (*signal_wps_event_success)(struct wpa_supplicant *wpa_s);
void (*signal_wps_event_fail)(struct wpa_supplicant *wpa_s,

View file

@ -735,190 +735,135 @@ DBusMessage * wpas_dbus_handler_get_interface(DBusMessage *message,
/**
* wpas_dbus_getter_debug_params - Get the debug params
* wpas_dbus_getter_debug_level - Get debug level
* @message: Pointer to incoming dbus message
* @global: %wpa_supplicant global data structure
* Returns: DBus message with struct containing debug params.
* Returns: DBus message with value of debug level
*
* Getter for "DebugParams" property.
* Getter for "DebugLevel" property.
*/
DBusMessage * wpas_dbus_getter_debug_params(DBusMessage *message,
DBusMessage * wpas_dbus_getter_debug_level(DBusMessage *message,
struct wpa_global *global)
{
DBusMessage *reply = NULL;
DBusMessageIter iter, variant_iter, struct_iter;
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BYTE,
&wpa_debug_level);
if (message == NULL)
reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
else
reply = dbus_message_new_method_return(message);
if (!reply) {
perror("wpas_dbus_getter_network_properties[dbus] out of "
"memory when trying to initialize return message");
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
dbus_message_iter_init_append(reply, &iter);
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
"(ibb)", &variant_iter)) {
perror("wpas_dbus_getter_debug_params[dbus] out of memory "
"when trying to open variant");
dbus_message_unref(reply);
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
if (!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_STRUCT,
NULL, &struct_iter)) {
perror("wpas_dbus_getter_debug_params[dbus] out of memory "
"when trying to open struct");
dbus_message_unref(reply);
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_INT32,
&wpa_debug_level)) {
perror("wpas_dbus_getter_debug_params[dbus] out of memory "
"when trying to append value to struct");
dbus_message_unref(reply);
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN,
&wpa_debug_timestamp)) {
perror("wpas_dbus_getter_debug_params[dbus] out of memory "
"when trying to append value to struct");
dbus_message_unref(reply);
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN,
&wpa_debug_show_keys)) {
perror("wpas_dbus_getter_debug_params[dbus] out of memory "
"when trying to append value to struct");
dbus_message_unref(reply);
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
if (!dbus_message_iter_close_container(&variant_iter, &struct_iter)) {
perror("wpas_dbus_getter_debug_params[dbus] out of memory "
"when trying to close struct");
dbus_message_unref(reply);
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
if (!dbus_message_iter_close_container(&iter, &variant_iter)) {
perror("wpas_dbus_getter_debug_params[dbus] out of memory "
"when trying to close variant");
dbus_message_unref(reply);
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
out:
return reply;
}
/**
* wpas_dbus_setter_debugparams - Set the debug params
* wpas_dbus_getter_debug_timestamp - Get debug timestamp
* @message: Pointer to incoming dbus message
* @global: %wpa_supplicant global data structure
* Returns: NULL indicating success or a dbus error message with more
* information
* Returns: DBus message with value of debug timestamp
*
* Setter for "DebugParams" property.
* Getter for "DebugTimestamp" property.
*/
DBusMessage * wpas_dbus_setter_debug_params(DBusMessage *message,
DBusMessage * wpas_dbus_getter_debug_timestamp(DBusMessage *message,
struct wpa_global *global)
{
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
&wpa_debug_timestamp);
}
/**
* wpas_dbus_getter_debug_show_keys - Get debug show keys
* @message: Pointer to incoming dbus message
* @global: %wpa_supplicant global data structure
* Returns: DBus message with value of debug show_keys
*
* Getter for "DebugShowKeys" property.
*/
DBusMessage * wpas_dbus_getter_debug_show_keys(DBusMessage *message,
struct wpa_global *global)
{
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
&wpa_debug_show_keys);
}
/**
* wpas_dbus_setter_debug_level - Set debug level
* @message: Pointer to incoming dbus message
* @global: %wpa_supplicant global data structure
* Returns: %NULL or DBus error message
*
* Setter for "DebugLevel" property.
*/
DBusMessage * wpas_dbus_setter_debug_level(DBusMessage *message,
struct wpa_global *global)
{
DBusMessage *reply = NULL;
DBusMessageIter iter, variant_iter, struct_iter;
int debug_level;
dbus_bool_t debug_timestamp;
dbus_bool_t debug_show_keys;
dbus_uint16_t val;
if (!dbus_message_iter_init(message, &iter)) {
perror("wpas_dbus_handler_add_blob[dbus] out of memory when "
"trying to initialize message iterator");
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
goto out;
}
dbus_message_iter_next(&iter);
dbus_message_iter_next(&iter);
dbus_message_iter_recurse(&iter, &variant_iter);
if (dbus_message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_STRUCT)
{
reply = wpas_dbus_error_invald_args(
message, "Argument must by a structure");
goto out;
}
dbus_message_iter_recurse(&variant_iter, &struct_iter);
if (dbus_message_iter_get_arg_type(&struct_iter) != DBUS_TYPE_INT32) {
reply = wpas_dbus_error_invald_args(
message, "First struct argument must by an INT32");
goto out;
}
dbus_message_iter_get_basic(&struct_iter, &debug_level);
if (!dbus_message_iter_next(&struct_iter)) {
reply = wpas_dbus_error_invald_args(
message, "Not enough elements in struct");
goto out;
}
if (dbus_message_iter_get_arg_type(&struct_iter) != DBUS_TYPE_BOOLEAN)
{
reply = wpas_dbus_error_invald_args(
message, "Second struct argument must by a boolean");
goto out;
}
dbus_message_iter_get_basic(&struct_iter, &debug_timestamp);
if (!dbus_message_iter_next(&struct_iter)) {
reply = wpas_dbus_error_invald_args(
message, "Not enough elements in struct");
goto out;
}
if (dbus_message_iter_get_arg_type(&struct_iter) != DBUS_TYPE_BOOLEAN)
{
reply = wpas_dbus_error_invald_args(
message, "Third struct argument must by an boolean");
goto out;
}
dbus_message_iter_get_basic(&struct_iter, &debug_show_keys);
if (wpa_supplicant_set_debug_params(global, debug_level,
debug_timestamp ? 1 : 0,
debug_show_keys ? 1 : 0)) {
reply = wpas_dbus_error_invald_args(
message, "Wrong debug level value");
goto out;
}
out:
reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_INT16,
&val);
if (reply)
return reply;
if (wpa_supplicant_set_debug_params(global, val, wpa_debug_timestamp,
wpa_debug_show_keys)) {
dbus_message_unref(reply);
return wpas_dbus_error_invald_args(
message, "Wrong debug level value");
}
return NULL;
}
/**
* wpas_dbus_setter_debug_timestamp - Set debug timestamp
* @message: Pointer to incoming dbus message
* @global: %wpa_supplicant global data structure
* Returns: %NULL or DBus error message
*
* Setter for "DebugTimestamp" property.
*/
DBusMessage * wpas_dbus_setter_debug_timestamp(DBusMessage *message,
struct wpa_global *global)
{
DBusMessage *reply = NULL;
dbus_bool_t val;
reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
&val);
if (reply)
return reply;
wpa_supplicant_set_debug_params(global, wpa_debug_level, val ? 1 : 0,
wpa_debug_show_keys);
return NULL;
}
/**
* wpas_dbus_setter_debug_show_keys - Set debug show keys
* @message: Pointer to incoming dbus message
* @global: %wpa_supplicant global data structure
* Returns: %NULL or DBus error message
*
* Setter for "DebugShowKeys" property.
*/
DBusMessage * wpas_dbus_setter_debug_show_keys(DBusMessage *message,
struct wpa_global *global)
{
DBusMessage *reply = NULL;
dbus_bool_t val;
reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
&val);
if (reply)
return reply;
wpa_supplicant_set_debug_params(global, wpa_debug_level,
wpa_debug_timestamp,
val ? 1 : 0);
return NULL;
}

View file

@ -46,10 +46,22 @@ DBusMessage * wpas_dbus_handler_remove_interface(DBusMessage *message,
DBusMessage * wpas_dbus_handler_get_interface(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_getter_debug_params(DBusMessage *message,
DBusMessage * wpas_dbus_getter_debug_level(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_setter_debug_params(DBusMessage *message,
DBusMessage * wpas_dbus_getter_debug_timestamp(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_getter_debug_show_keys(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_setter_debug_level(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_setter_debug_timestamp(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_setter_debug_show_keys(DBusMessage *message,
struct wpa_global *global);
DBusMessage * wpas_dbus_getter_interfaces(DBusMessage *message,

View file

@ -267,9 +267,25 @@ void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
}
void wpas_notify_debug_params_changed(struct wpa_global *global)
void wpas_notify_debug_level_changed(struct wpa_global *global)
{
struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
if (cbs)
cbs->signal_debug_params_changed(global);
cbs->signal_debug_level_changed(global);
}
void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
{
struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
if (cbs)
cbs->signal_debug_timestamp_changed(global);
}
void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
{
struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
if (cbs)
cbs->signal_debug_show_keys_changed(global);
}

View file

@ -54,6 +54,8 @@ void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, u8 bssid[],
void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name);
void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name);
void wpas_notify_debug_params_changed(struct wpa_global *global);
void wpas_notify_debug_level_changed(struct wpa_global *global);
void wpas_notify_debug_timestamp_changed(struct wpa_global *global);
void wpas_notify_debug_show_keys_changed(struct wpa_global *global);
#endif /* NOTIFY_H */

View file

@ -1556,10 +1556,12 @@ int wpa_supplicant_set_debug_params(struct wpa_global *global, int debug_level,
wpa_debug_timestamp = debug_timestamp ? 1 : 0;
wpa_debug_show_keys = debug_show_keys ? 1 : 0;
if (wpa_debug_level != old_level ||
wpa_debug_timestamp != old_timestamp ||
wpa_debug_show_keys != old_show_keys)
wpas_notify_debug_params_changed(global);
if (wpa_debug_level != old_level)
wpas_notify_debug_level_changed(global);
if (wpa_debug_timestamp != old_timestamp)
wpas_notify_debug_timestamp_changed(global);
if (wpa_debug_show_keys != old_show_keys)
wpas_notify_debug_show_keys_changed(global);
return 0;
}