[PATCH 4/4] dbus: Add D-Bus method for current authentication mode

Paul Stewart pstew
Thu Mar 10 11:04:40 PST 2011


Chooses between EAP and non-EAP authentication modes and
uses the appropriate method to retrieve the name.

Signed-off-by: Paul Stewart <pstew at google.com>
---
 wpa_supplicant/dbus/dbus_new.c          |    4 +++
 wpa_supplicant/dbus/dbus_new_handlers.c |   39 +++++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers.h |    3 ++
 wpa_supplicant/dbus/dbus_new_helpers.h  |    1 +
 4 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index c66640a..7562c94 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -1388,6 +1388,10 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
 	  (WPADBusPropertyAccessor) wpas_dbus_getter_current_network,
 	  NULL, R
 	},
+	{ "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
+	  (WPADBusPropertyAccessor) wpas_dbus_getter_current_auth_mode,
+	  NULL, R
+	},
 	{ "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
 	  (WPADBusPropertyAccessor) wpas_dbus_getter_blobs,
 	  NULL, R
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 5402bff..3f129a0 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -2192,6 +2192,45 @@ DBusMessage * wpas_dbus_getter_current_network(DBusMessage *message,
 
 
 /**
+ * wpas_dbus_getter_current_auth_mode - Get current authentication type
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: A dbus message containing a string indicating the current
+ * authentication type.
+ *
+ * Getter for "CurrentAuthMode" property.
+ */
+DBusMessage * wpas_dbus_getter_current_auth_mode(DBusMessage *message,
+						 struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply;
+	const char *eap_mode;
+	const char *auth_mode;
+	char eap_mode_buf[WPAS_DBUS_AUTH_MODE_MAX];
+
+	if (wpa_s->wpa_state != WPA_COMPLETED) {
+		auth_mode = "INACTIVE";
+	} else if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X ||
+	    wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
+		eap_mode = wpa_supplicant_get_eap_mode(wpa_s);
+		os_snprintf(eap_mode_buf, WPAS_DBUS_AUTH_MODE_MAX,
+			    "EAP-%s", eap_mode);
+		auth_mode = eap_mode_buf;
+
+	} else {
+		auth_mode = wpa_key_mgmt_txt(wpa_s->key_mgmt,
+					     wpa_s->current_ssid->proto);
+	}
+
+	reply = wpas_dbus_simple_property_getter(message,
+						 DBUS_TYPE_STRING,
+						 &auth_mode);
+
+	return reply;
+}
+
+
+/**
  * wpas_dbus_getter_bridge_ifname - Get interface name
  * @message: Pointer to incoming dbus message
  * @wpa_s: wpa_supplicant structure for a network interface
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index 3cdf9cb..119d15d 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -125,6 +125,9 @@ DBusMessage * wpas_dbus_getter_current_bss(DBusMessage *message,
 DBusMessage * wpas_dbus_getter_current_network(DBusMessage *message,
 					       struct wpa_supplicant *wpa_s);
 
+DBusMessage * wpas_dbus_getter_current_auth_mode(DBusMessage *message,
+						 struct wpa_supplicant *wpa_s);
+
 DBusMessage * wpas_dbus_getter_bsss(DBusMessage *message,
 				    struct wpa_supplicant *wpa_s);
 
diff --git a/wpa_supplicant/dbus/dbus_new_helpers.h b/wpa_supplicant/dbus/dbus_new_helpers.h
index 8db7a37..7038b63 100644
--- a/wpa_supplicant/dbus/dbus_new_helpers.h
+++ b/wpa_supplicant/dbus/dbus_new_helpers.h
@@ -104,6 +104,7 @@ struct wpa_dbus_property_desc {
 #define WPAS_DBUS_OBJECT_PATH_MAX 150
 #define WPAS_DBUS_INTERFACE_MAX 150
 #define WPAS_DBUS_METHOD_SIGNAL_PROP_MAX 50
+#define WPAS_DBUS_AUTH_MODE_MAX 64
 
 #define WPA_DBUS_INTROSPECTION_INTERFACE "org.freedesktop.DBus.Introspectable"
 #define WPA_DBUS_INTROSPECTION_METHOD "Introspect"
-- 
1.7.3.1




More information about the Hostap mailing list