]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Implement EAP SM control request signals
authorDan Williams <dcbw@redhat.com>
Mon, 24 Oct 2011 16:03:04 +0000 (11:03 -0500)
committerJouni Malinen <j@w1.fi>
Sun, 30 Oct 2011 10:04:24 +0000 (12:04 +0200)
Add a D-Bus signal for EAP SM requests. This signal is emitted on the
Interface object so that clients only have to listen to one object for
requests rather than to all network objects. This signal is analogous
to the socket control interface's CTRL-REQ- request.

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

index 40e3f4a3b9864361cbcb1b7f71a07d45ffbb75a8..03d514c5c63dc4bf9be8e6ec485a11888933bcfc 100644 (file)
@@ -22,6 +22,7 @@
 #include "../config.h"
 #include "../wpa_supplicant_i.h"
 #include "../bss.h"
+#include "../wpas_glue.h"
 #include "dbus_new_helpers.h"
 #include "dbus_dict_helpers.h"
 #include "dbus_new.h"
@@ -381,6 +382,67 @@ void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id)
 }
 
 
+/**
+ * wpas_dbus_signal_network_request - Indicate that additional information
+ * (EAP password, etc.) is required to complete the association to this SSID
+ * @wpa_s: %wpa_supplicant network interface data
+ * @rtype: The specific additional information required
+ * @default_text: Optional description of required information
+ *
+ * Request additional information or passwords to complete an association
+ * request.
+ */
+void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
+                                     struct wpa_ssid *ssid,
+                                     enum wpa_ctrl_req_type rtype,
+                                     const char *default_txt)
+{
+       struct wpas_dbus_priv *iface;
+       DBusMessage *msg;
+       DBusMessageIter iter;
+       char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+       const char *field, *txt = NULL, *net_ptr;
+
+       iface = wpa_s->global->dbus;
+
+       /* Do nothing if the control interface is not turned on */
+       if (iface == NULL)
+               return;
+
+       field = wpa_supplicant_ctrl_req_to_string(rtype, default_txt, &txt);
+       if (field == NULL)
+               return;
+
+       msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+                                     WPAS_DBUS_NEW_IFACE_INTERFACE,
+                                     "NetworkRequest");
+       if (msg == NULL)
+               return;
+
+       os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+                   "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
+                   wpa_s->dbus_new_path, ssid->id);
+       net_ptr = &net_obj_path[0];
+
+       dbus_message_iter_init_append(msg, &iter);
+       if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+                                           &net_ptr))
+               goto err;
+       if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field))
+               goto err;
+       if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &txt))
+               goto err;
+
+       dbus_connection_send(iface->con, msg, NULL);
+       dbus_message_unref(msg);
+       return;
+
+err:
+       wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+       dbus_message_unref(msg);
+}
+
+
 /**
  * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
  * @wpa_s: %wpa_supplicant network interface data
@@ -1689,6 +1751,14 @@ static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
                  END_ARGS
          }
        },
+       { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
+         {
+                 { "path", "o", ARG_OUT },
+                 { "field", "s", ARG_OUT },
+                 { "text", "s", ARG_OUT },
+                 END_ARGS
+         }
+       },
        /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
        { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
          {
index 080000c070ca64ce052ee9e9856caf4390ff519e..f4a830a186a846644458ef8ab470fe307cff2c98 100644 (file)
@@ -25,6 +25,7 @@ struct wps_event_m2d;
 struct wps_event_fail;
 struct wps_credential;
 enum wpa_states;
+enum wpa_ctrl_req_type;
 
 enum wpas_dbus_prop {
        WPAS_DBUS_PROP_AP_SCAN,
@@ -131,6 +132,10 @@ void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
                                              struct wpa_ssid *ssid);
 void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id);
+void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
+                                     struct wpa_ssid *ssid,
+                                     enum wpa_ctrl_req_type rtype,
+                                     const char *default_text);
 void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success);
 void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
                               const struct wps_credential *cred);
@@ -241,6 +246,12 @@ static inline void wpas_dbus_signal_network_selected(
 {
 }
 
+static inline void wpas_dbus_signal_network_request(
+       struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
+       enum wpa_ctrl_req_type rtype, const char *default_txt)
+{
+}
+
 static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s,
                                              int success)
 {
index 87f4da5aa76f84e8f70e1757673f07eb15c6d05f..768f82326a300a0971c239bbe51b954649d9d4ce 100644 (file)
@@ -78,7 +78,7 @@ struct wpa_dbus_signal_desc {
        /* signal interface */
        const char *dbus_interface;
        /* array of arguments */
-       struct wpa_dbus_argument args[3];
+       struct wpa_dbus_argument args[4];
 };
 
 /**
index 75b9acf37e686d0a66bd991bd7cbe25c454d436c..cf8234654ff497c89051e3e4d420a1c53bfb7a25 100644 (file)
@@ -141,6 +141,15 @@ void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
 }
 
 
+void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
+                                struct wpa_ssid *ssid,
+                                enum wpa_ctrl_req_type rtype,
+                                const char *default_txt)
+{
+       wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
+}
+
+
 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
 {
        /* notify the old DBus API */
index 98cbcb1b3dca09797c0f333e0c9fc47781f1a7f6..70950c6119e4ad57df62b20ae35f2afe08076a85 100644 (file)
@@ -36,6 +36,10 @@ void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
                                         struct wpa_ssid *ssid);
 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
                                  struct wpa_ssid *ssid);
+void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
+                                struct wpa_ssid *ssid,
+                                enum wpa_ctrl_req_type rtype,
+                                const char *default_txt);
 void wpas_notify_scanning(struct wpa_supplicant *wpa_s);
 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success);
 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s);
index e4cb6137f38bbe696679066b23ecc73a1d4b456d..4cd20330461b058a4bd1a2807475862621c18c7d 100644 (file)
@@ -648,6 +648,8 @@ static void wpa_supplicant_eap_param_needed(void *ctx,
        if (ssid == NULL)
                return;
 
+       wpas_notify_network_request(wpa_s, ssid, field, default_txt);
+
        field_name = wpa_supplicant_ctrl_req_to_string(field, default_txt,
                                                       &txt);
        if (field_name == NULL) {