[PATCH] dbus ctrl interface: add interface 'state' method

Dan Williams dcbw
Mon Dec 4 12:02:57 PST 2006


There is currently a state change signal, but no way to get the initial
interface state.  This patch adds that method.

Dan

--- wpa_supplicant/ctrl_iface_dbus_handlers.c.foo	2006-12-04 14:26:36.000000000 -0500
+++ wpa_supplicant/ctrl_iface_dbus_handlers.c	2006-12-04 14:33:56.000000000 -0500
@@ -1173,3 +1173,27 @@
 out:
 	return reply;
 }
+
+/**
+ * wpas_dbus_iface_get_state - Get interface state
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: A dbus message containing a STRING representing the current
+ *          interface state
+ *
+ * Handler function for "state" method call.
+ */
+DBusMessage * wpas_dbus_iface_get_state(DBusMessage *message,
+					  struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply = NULL;
+	const char * str_state;
+
+	reply = dbus_message_new_method_return(message);
+	if (reply != NULL) {
+		str_state = wpa_supplicant_state_txt(wpa_s->wpa_state);
+		dbus_message_append_args(message, DBUS_TYPE_STRING, &str_state, DBUS_TYPE_INVALID);
+	}
+
+	return reply;
+}
--- wpa_supplicant/ctrl_iface_dbus_handlers.h.foo	2006-12-04 14:31:22.000000000 -0500
+++ wpa_supplicant/ctrl_iface_dbus_handlers.h	2006-12-04 14:32:01.000000000 -0500
@@ -68,6 +68,9 @@
 DBusMessage * wpas_dbus_iface_set_ap_scan(DBusMessage *message,
                                           struct wpa_supplicant *wpa_s);
 
+DBusMessage * wpas_dbus_iface_get_state(DBusMessage *message,
+                                        struct wpa_supplicant *wpa_s);
+
 #endif /* CONFIG_CTRL_IFACE_DBUS */
 
 #endif /* CTRL_IFACE_DBUS_HANDLERS_H */
--- wpa_supplicant/ctrl_iface_dbus.c.foo	2006-12-04 14:26:51.000000000 -0500
+++ wpa_supplicant/ctrl_iface_dbus.c	2006-12-04 14:27:52.000000000 -0500
@@ -530,6 +530,8 @@
 			reply = wpas_dbus_iface_disconnect(message, wpa_s);
 		else if (!strcmp(method, "setAPScan"))
 			reply = wpas_dbus_iface_set_ap_scan(message, wpa_s);
+		else if (!strcmp(method, "state"))
+			reply = wpas_dbus_iface_get_state(message, wpa_s);
 	}
 
 	/* If the message was handled, send back the reply */

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctrl-iface-dbus-iface-state.patch
Type: text/x-patch
Size: 1970 bytes
Desc: not available
Url : http://lists.shmoo.com/pipermail/hostap/attachments/20061204/66e09dff/attachment.bin 



More information about the Hostap mailing list