]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Implement control request replies for the D-Bus interface
authorDan Williams <dcbw@redhat.com>
Mon, 24 Oct 2011 16:09:06 +0000 (11:09 -0500)
committerJouni Malinen <j@w1.fi>
Sun, 30 Oct 2011 10:04:24 +0000 (12:04 +0200)
Add a D-Bus mechanism for clients to respond to the NetworkRequest
signal.

Signed-off-by: Dan Williams <dcbw@redhat.com>
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/dbus/dbus_new_handlers.h
wpa_supplicant/dbus/dbus_new_helpers.h

index 03d514c5c63dc4bf9be8e6ec485a11888933bcfc..a67eadd54e2e9b170731056ab558ce997aefa304 100644 (file)
@@ -2188,6 +2188,15 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
                  END_ARGS
          }
        },
+       { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE,
+         (WPADBusMethodHandler) &wpas_dbus_handler_network_reply,
+         {
+                 { "path", "o", ARG_IN },
+                 { "field", "s", ARG_IN },
+                 { "value", "s", ARG_IN },
+                 END_ARGS
+         }
+       },
        { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
          (WPADBusMethodHandler) &wpas_dbus_handler_add_blob,
          {
index bb68079c89130ebcf7c16f0fb9c49e8f1e9e2b8d..634efcb8fccc8e0c935fe9f1ea5bd5aa6ae89f79 100644 (file)
@@ -28,6 +28,7 @@
 #include "../wpas_glue.h"
 #include "../bss.h"
 #include "../scan.h"
+#include "../ctrl_iface.h"
 #include "dbus_new_helpers.h"
 #include "dbus_new.h"
 #include "dbus_new_handlers.h"
@@ -1473,6 +1474,70 @@ out:
 }
 
 
+/**
+ * wpas_dbus_handler_network_reply - Reply to a NetworkRequest signal
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: NULL on success or dbus error on failure
+ *
+ * Handler function for "NetworkReply" method call of network interface.
+ */
+DBusMessage * wpas_dbus_handler_network_reply(DBusMessage *message,
+                                             struct wpa_supplicant *wpa_s)
+{
+#ifdef IEEE8021X_EAPOL
+       DBusMessage *reply = NULL;
+       const char *op, *field, *value;
+       char *iface = NULL, *net_id = NULL;
+       int id;
+       struct wpa_ssid *ssid;
+
+       if (!dbus_message_get_args(message, NULL,
+                                  DBUS_TYPE_OBJECT_PATH, &op,
+                                  DBUS_TYPE_STRING, &field,
+                                  DBUS_TYPE_STRING, &value,
+                                  DBUS_TYPE_INVALID))
+               return wpas_dbus_error_invalid_args(message, NULL);
+
+       /* Extract the network ID and ensure the network */
+       /* is actually a child of this interface */
+       iface = wpas_dbus_new_decompose_object_path(op, 0, &net_id, NULL);
+       if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
+               reply = wpas_dbus_error_invalid_args(message, op);
+               goto out;
+       }
+
+       id = strtoul(net_id, NULL, 10);
+       if (errno == EINVAL) {
+               reply = wpas_dbus_error_invalid_args(message, net_id);
+               goto out;
+       }
+
+       ssid = wpa_config_get_network(wpa_s->conf, id);
+       if (ssid == NULL) {
+               reply = wpas_dbus_error_network_unknown(message);
+               goto out;
+       }
+
+       if (wpa_supplicant_ctrl_iface_ctrl_rsp_handle(wpa_s, ssid,
+                                                     field, value) < 0)
+               reply = wpas_dbus_error_invalid_args(message, field);
+       else {
+               /* Tell EAP to retry immediately */
+               eapol_sm_notify_ctrl_response(wpa_s->eapol);
+       }
+
+out:
+       os_free(iface);
+       os_free(net_id);
+       return reply;
+#else /* IEEE8021X_EAPOL */
+       wpa_printf(MSG_DEBUG, "CTRL_IFACE: 802.1X not included");
+       return wpas_dbus_error_unknown_error(message, "802.1X not included");
+#endif /* IEEE8021X_EAPOL */
+}
+
+
 /**
  * wpas_dbus_handler_add_blob - Store named binary blob (ie, for certificates)
  * @message: Pointer to incoming dbus message
index 8093033e0bad9ced58be8de061967ace618d4346..ac3af1ffcd0e1cac5379158875b782ad4274b298 100644 (file)
@@ -103,6 +103,9 @@ DBusMessage * wpas_dbus_handler_remove_all_networks(
 DBusMessage * wpas_dbus_handler_select_network(DBusMessage *message,
                                               struct wpa_supplicant *wpa_s);
 
+DBusMessage * wpas_dbus_handler_network_reply(DBusMessage *message,
+                                             struct wpa_supplicant *wpa_s);
+
 DBusMessage * wpas_dbus_handler_add_blob(DBusMessage *message,
                                         struct wpa_supplicant *wpa_s);
 
index 768f82326a300a0971c239bbe51b954649d9d4ce..d6e7b48aa4ed4beb5c99f2b9549e297e28db4f1a 100644 (file)
@@ -66,7 +66,7 @@ struct wpa_dbus_method_desc {
        /* method handling function */
        WPADBusMethodHandler method_handler;
        /* array of arguments */
-       struct wpa_dbus_argument args[3];
+       struct wpa_dbus_argument args[4];
 };
 
 /**