[PATCH] dbus: Use simple strings for debug level
Marcel Holtmann
marcel
Sun Jan 3 16:38:22 PST 2010
Instead of using some magic integer values that really only mean
something to WPA internal code, just use simple strings. Possible
values are "msgdump", "debug", "info", "warning" and "error" which
map directly to WPA debugging support.
---
doc/dbus.doxygen | 6 ++--
wpa_supplicant/dbus/dbus_new.c | 2 +-
wpa_supplicant/dbus/dbus_new_handlers.c | 34 +++++++++++++++++++++---------
3 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index 6f40b2d..9deb28d 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -98,10 +98,10 @@ registered in the bus with fi.w1.wpa_supplicant1 name.
<ul>
<li>
- <h3>DebugLevel - y - (read/write)</h3>
+ <h3>DebugLevel - s - (read/write)</h3>
<p>Global %wpa_supplicant debugging level. Possible values are
- 0 (verbose debugging), 1 (debugging), 2 (informative), 3 (warnings),
- and 4 (errors).</p>
+ "msgdump" (verbose debugging), "debug" (debugging),
+ "info" (informative), "warning" (warnings), and "error" (errors).</p>
</li>
<li>
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 2b2a24c..1633b96 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -863,7 +863,7 @@ static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
};
static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
- { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "y",
+ { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
(WPADBusPropertyAccessor) wpas_dbus_getter_debug_level,
(WPADBusPropertyAccessor) wpas_dbus_setter_debug_level,
RW
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 5f521d4..a3a7015 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -36,6 +36,10 @@ extern int wpa_debug_level;
extern int wpa_debug_show_keys;
extern int wpa_debug_timestamp;
+static const char *debug_strings[] = {
+ "msgdump", "debug", "info", "warning", "error", NULL
+};
+
/**
* wpas_dbus_new_decompose_object_path - Decompose an interface object path into parts
@@ -706,8 +710,10 @@ DBusMessage * wpas_dbus_handler_get_interface(DBusMessage *message,
DBusMessage * wpas_dbus_getter_debug_level(DBusMessage *message,
struct wpa_global *global)
{
- return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BYTE,
- &wpa_debug_level);
+ const char *str = debug_strings[wpa_debug_level];
+
+ return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
+ &str);
}
@@ -756,16 +762,24 @@ DBusMessage * wpas_dbus_getter_debug_show_keys(DBusMessage *message,
DBusMessage * wpas_dbus_setter_debug_level(DBusMessage *message,
struct wpa_global *global)
{
- DBusMessage *reply = NULL;
- dbus_uint16_t val;
+ DBusMessage *reply;
+ const char *str = NULL;
+ int i, val = -1;
- reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_INT16,
- &val);
+ reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_STRING,
+ &str);
if (reply)
return reply;
- if (wpa_supplicant_set_debug_params(global, val, wpa_debug_timestamp,
- wpa_debug_show_keys)) {
+ for (i = 0; debug_strings[i]; i++)
+ if (!strcmp(debug_strings[i], str)) {
+ val = i;
+ break;
+ }
+
+ if (val < 0 || wpa_supplicant_set_debug_params(global, val,
+ wpa_debug_timestamp,
+ wpa_debug_show_keys)) {
dbus_message_unref(reply);
return wpas_dbus_error_invalid_args(
message, "Wrong debug level value");
@@ -786,7 +800,7 @@ DBusMessage * wpas_dbus_setter_debug_level(DBusMessage *message,
DBusMessage * wpas_dbus_setter_debug_timestamp(DBusMessage *message,
struct wpa_global *global)
{
- DBusMessage *reply = NULL;
+ DBusMessage *reply;
dbus_bool_t val;
reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
@@ -812,7 +826,7 @@ DBusMessage * wpas_dbus_setter_debug_timestamp(DBusMessage *message,
DBusMessage * wpas_dbus_setter_debug_show_keys(DBusMessage *message,
struct wpa_global *global)
{
- DBusMessage *reply = NULL;
+ DBusMessage *reply;
dbus_bool_t val;
reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
--
1.6.5.2
More information about the Hostap
mailing list