#include "eloop.h"
#include "config.h"
#include "wpa_supplicant_i.h"
+#include "drivers/driver.h"
+#include "wps/wps.h"
#include "ctrl_iface_dbus.h"
#include "ctrl_iface_dbus_handlers.h"
-#define DBUS_VERSION (DBUS_VERSION_MAJOR << 8 | DBUS_VERSION_MINOR)
+#define _DBUS_VERSION (DBUS_VERSION_MAJOR << 8 | DBUS_VERSION_MINOR)
#define DBUS_VER(major, minor) ((major) << 8 | (minor))
-#if DBUS_VERSION < DBUS_VER(1,1)
+#if _DBUS_VERSION < DBUS_VER(1,1)
#define dbus_watch_get_unix_fd dbus_watch_get_fd
#endif
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, "setSmartcardModules"))
+ reply = wpas_dbus_iface_set_smartcard_modules(message,
+ wpa_s);
else if (!strcmp(method, "state"))
reply = wpas_dbus_iface_get_state(message, wpa_s);
else if (!strcmp(method, "setBlobs"))
reply = wpas_dbus_iface_set_blobs(message, wpa_s);
else if (!strcmp(method, "removeBlobs"))
reply = wpas_dbus_iface_remove_blobs(message, wpa_s);
+#ifdef CONFIG_WPS
+ else if (!os_strcmp(method, "wpsPbc"))
+ reply = wpas_dbus_iface_wps_pbc(message, wpa_s);
+ else if (!os_strcmp(method, "wpsPin"))
+ reply = wpas_dbus_iface_wps_pin(message, wpa_s);
+ else if (!os_strcmp(method, "wpsReg"))
+ reply = wpas_dbus_iface_wps_reg(message, wpa_s);
+#endif /* CONFIG_WPS */
}
/* If the message was handled, send back the reply */
if (reply) {
- dbus_connection_send(connection, reply, NULL);
+ if (!dbus_message_get_no_reply(message))
+ dbus_connection_send(connection, reply, NULL);
dbus_message_unref(reply);
}
} else if (!strcmp(method, "getInterface")) {
reply = wpas_dbus_global_get_interface(
message, ctrl_iface->global);
+ } else if (!strcmp(method, "setDebugParams")) {
+ reply = wpas_dbus_global_set_debugparams(
+ message, ctrl_iface->global);
}
}
/* If the message was handled, send back the reply */
if (reply) {
- dbus_connection_send(connection, reply, NULL);
+ if (!dbus_message_get_no_reply(message))
+ dbus_connection_send(connection, reply, NULL);
dbus_message_unref(reply);
}
}
+#ifdef CONFIG_WPS
+void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
+ const struct wps_credential *cred)
+{
+ struct ctrl_iface_dbus_priv *iface;
+ DBusMessage *_signal = NULL;
+ const char *path;
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s->global == NULL)
+ return;
+ iface = wpa_s->global->dbus_ctrl_iface;
+ if (iface == NULL)
+ return;
+
+ path = wpa_supplicant_get_dbus_path(wpa_s);
+ if (path == NULL) {
+ perror("wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+ "interface didn't have a dbus path");
+ wpa_printf(MSG_ERROR,
+ "wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+ "interface didn't have a dbus path; can't send "
+ "signal.");
+ return;
+ }
+ _signal = dbus_message_new_signal(path, WPAS_DBUS_IFACE_INTERFACE,
+ "WpsCred");
+ if (_signal == NULL) {
+ perror("wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+ "couldn't create dbus signal; likely out of memory");
+ wpa_printf(MSG_ERROR,
+ "wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+ "couldn't create dbus signal; likely out of "
+ "memory.");
+ return;
+ }
+
+ if (!dbus_message_append_args(_signal,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+ &cred->cred_attr, cred->cred_attr_len,
+ DBUS_TYPE_INVALID)) {
+ perror("wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+ "not enough memory to construct signal.");
+ wpa_printf(MSG_ERROR,
+ "wpa_supplicant_dbus_notify_wps_cred[dbus]: "
+ "not enough memory to construct signal.");
+ goto out;
+ }
+
+ dbus_connection_send(iface->con, _signal, NULL);
+
+out:
+ dbus_message_unref(_signal);
+}
+#endif /* CONFIG_WPS */
+
+
/**
* integrate_with_eloop - Register our mainloop integration with dbus
* @connection: connection to the system message bus
/**
* wpas_dbus_register_new_iface - Register a new interface with dbus
- * @global: Global %wpa_supplicant data
* @wpa_s: %wpa_supplicant interface description structure to register
* Returns: 0 on success, -1 on error
*