]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Divide DebugParams property to three separate properties
authorWitold Sowa <witold.sowa@gmail.com>
Fri, 1 Jan 2010 11:00:22 +0000 (13:00 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 1 Jan 2010 11:00:22 +0000 (13:00 +0200)
doc/dbus.doxygen
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new.h
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/dbus/dbus_new_handlers.h
wpa_supplicant/notify.c
wpa_supplicant/notify.h
wpa_supplicant/wpa_supplicant.c

index 9f5f17ea02a5aa3024a96a1c54c5e1216a9cc11f..020353dd5d1043f1c41f493d46260527f57e671b 100644 (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>
index 6d212073a03f29aec25e14203263e45cb9c5cdbc..de31c94d495be3e741af7216e5256939b7fce204 100644 (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_level,
+                                        global, WPAS_DBUS_NEW_PATH,
+                                        WPAS_DBUS_NEW_INTERFACE,
+                                        "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_params,
+                                        wpas_dbus_getter_debug_show_keys,
                                         global, WPAS_DBUS_NEW_PATH,
                                         WPAS_DBUS_NEW_INTERFACE,
-                                        "DebugParams");
+                                        "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,
index 7126e2f73ab7641f507189e99cec0cdfa9420a6e..01de05599cd05b8b2d83a39ee508fb105622e94d 100644 (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,
index 9092287d6d201dc5f7da5b1b04ce510443e7197b..91f08e09a5a3be76fa28eb6304c681771929b4ac 100644 (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,
-                                           struct wpa_global *global)
+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;
-       }
+/**
+ * wpas_dbus_getter_debug_timestamp - Get debug timestamp
+ * @message: Pointer to incoming dbus message
+ * @global: %wpa_supplicant global data structure
+ * Returns: DBus message with value of debug timestamp
+ *
+ * Getter for "DebugTimestamp" property.
+ */
+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);
 
-       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;
-       }
+/**
+ * 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);
 
-       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;
-       }
+/**
+ * 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;
+       dbus_uint16_t val;
 
-       if (!dbus_message_iter_close_container(&iter, &variant_iter)) {
-               perror("wpas_dbus_getter_debug_params[dbus] out of memory "
-                      "when trying to close variant");
+       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);
-               reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
-                                              NULL);
-               goto out;
+               return wpas_dbus_error_invald_args(
+                       message, "Wrong debug level value");
        }
 
-out:
-       return reply;
+       return NULL;
 }
 
 
 /**
- * wpas_dbus_setter_debugparams - Set the debug params
+ * wpas_dbus_setter_debug_timestamp - Set 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: %NULL or DBus error message
  *
- * Setter for "DebugParams" property.
+ * Setter for "DebugTimestamp" property.
  */
-DBusMessage * wpas_dbus_setter_debug_params(DBusMessage *message,
-                                           struct wpa_global *global)
+DBusMessage * wpas_dbus_setter_debug_timestamp(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_bool_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);
+       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);
 
-       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;
-       }
+       return NULL;
+}
 
-       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;
-       }
+/**
+ * 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;
 
-       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);
+       reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_BOOLEAN,
+                                                &val);
+       if (reply)
+               return reply;
 
-       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;
-       }
+       wpa_supplicant_set_debug_params(global, wpa_debug_level,
+                                       wpa_debug_timestamp,
+                                       val ? 1 : 0);
 
-out:
-       return reply;
+       return NULL;
 }
 
 
index 9a68c273a9a1598f345fade38b10da3a168cafb0..6a9854dc309fc126e7eac91d3b8e51bf068e5175 100644 (file)
@@ -46,11 +46,23 @@ 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,
-                                           struct wpa_global *global);
+DBusMessage * wpas_dbus_getter_debug_level(DBusMessage *message,
+                                          struct wpa_global *global);
 
-DBusMessage * wpas_dbus_setter_debug_params(DBusMessage *message,
-                                           struct wpa_global *global);
+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,
                                          struct wpa_global *global);
index a95ce03157cc6abf4ac64d40e7838e2ae5648e1b..17b497661498483c2ba9481958a9fb54383a067e 100644 (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);
 }
index 02f87a3e5300c638f87625bee440d829d21e0837..4cdd2554e679a1e53ee9112319002af9a104974a 100644 (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 */
index 3f05616ced54cf2290d2b718d2641e7f1bffb54c..e2dd31cc7abbe2b9b55c1a8697610d14fce7ff51 100644 (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;
 }