dbus: Use simple strings for debug level

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.
This commit is contained in:
Marcel Holtmann 2010-01-04 16:22:26 +02:00 committed by Jouni Malinen
parent 3adca61c9c
commit a2753c285f
3 changed files with 32 additions and 14 deletions

View file

@ -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>

View file

@ -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

View file

@ -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,9 +710,15 @@ 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;
int idx = wpa_debug_level;
if (idx < 0)
idx = 0;
if (idx > 4)
idx = 4;
str = debug_strings[idx];
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
&str);
}
@ -756,15 +766,23 @@ 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,
for (i = 0; debug_strings[i]; i++)
if (os_strcmp(debug_strings[i], str) == 0) {
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(
@ -786,7 +804,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 +830,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,