#include "common.h"
#include "eloop.h"
-#include "drivers/driver.h"
#include "wps/wps.h"
#include "../config.h"
#include "../wpa_supplicant_i.h"
+#include "../bss.h"
#include "dbus_old.h"
#include "dbus_old_handlers.h"
#include "dbus_common.h"
*/
static DBusMessage * wpas_dispatch_bssid_method(DBusMessage *message,
struct wpa_supplicant *wpa_s,
- const char *bssid)
+ const char *bssid_txt)
{
- DBusMessage *reply = NULL;
- const char *method = dbus_message_get_member(message);
- struct wpa_scan_res *res = NULL;
- size_t i;
-
- /* Ensure we actually have scan data */
- if (wpa_s->scan_res == NULL &&
- wpa_supplicant_get_scan_results(wpa_s) < 0) {
- reply = wpas_dbus_new_invalid_bssid_error(message);
- goto out;
- }
+ u8 bssid[ETH_ALEN];
+ struct wpa_bss *bss;
- /* Find the bssid's scan data */
- for (i = 0; i < wpa_s->scan_res->num; i++) {
- struct wpa_scan_res *search_res = wpa_s->scan_res->res[i];
- char mac_str[18];
-
- memset(mac_str, 0, sizeof(mac_str));
- snprintf(mac_str, sizeof(mac_str) - 1, WPAS_DBUS_BSSID_FORMAT,
- MAC2STR(search_res->bssid));
- if (!strcmp(bssid, mac_str)) {
- res = search_res;
- break;
- }
- }
+ if (hexstr2bin(bssid_txt, bssid, ETH_ALEN) < 0)
+ return wpas_dbus_new_invalid_bssid_error(message);
- if (!res) {
- reply = wpas_dbus_new_invalid_bssid_error(message);
- goto out;
- }
+ bss = wpa_bss_get_bssid(wpa_s, bssid);
+ if (bss == NULL)
+ return wpas_dbus_new_invalid_bssid_error(message);
/* Dispatch the method call against the scanned bssid */
- if (!strcmp(method, "properties"))
- reply = wpas_dbus_bssid_properties(message, wpa_s, res);
+ if (os_strcmp(dbus_message_get_member(message), "properties") == 0)
+ return wpas_dbus_bssid_properties(message, wpa_s, bss);
-out:
- return reply;
+ return NULL;
}
WPAS_DBUS_IFACE_INTERFACE,
"ScanResultsAvailable");
if (_signal == NULL) {
- perror("wpa_supplicant_dbus_notify_scan_results[dbus]: "
- "couldn't create dbus signal; likely out of memory");
- wpa_printf(MSG_ERROR, "dbus control interface: not enough "
- "memory to send scan results signal.");
+ wpa_printf(MSG_ERROR, "dbus: Not enough memory to send scan "
+ "results signal");
return;
}
dbus_connection_send(iface->con, _signal, NULL);
DBusMessage *_signal = NULL;
const char *new_state_str, *old_state_str;
+ if (wpa_s->dbus_path == NULL)
+ return; /* Skip signal since D-Bus setup is not yet ready */
+
/* Do nothing if the control interface is not turned on */
if (wpa_s->global == NULL)
return;
WPAS_DBUS_IFACE_INTERFACE,
"StateChange");
if (_signal == NULL) {
- perror("wpa_supplicant_dbus_notify_state_change[dbus]: "
- "couldn't create dbus signal; likely out of memory");
wpa_printf(MSG_ERROR,
- "wpa_supplicant_dbus_notify_state_change[dbus]: "
- "couldn't create dbus signal; likely out of "
- "memory.");
+ "dbus: wpa_supplicant_dbus_notify_state_change: "
+ "could not create dbus signal; likely out of "
+ "memory");
return;
}
new_state_str = wpa_supplicant_state_txt(new_state);
old_state_str = wpa_supplicant_state_txt(old_state);
if (new_state_str == NULL || old_state_str == NULL) {
- perror("wpa_supplicant_dbus_notify_state_change[dbus]: "
- "couldn't convert state strings");
wpa_printf(MSG_ERROR,
- "wpa_supplicant_dbus_notify_state_change[dbus]: "
- "couldn't convert state strings.");
+ "dbus: wpa_supplicant_dbus_notify_state_change: "
+ "Could not convert state strings");
goto out;
}
DBUS_TYPE_STRING, &new_state_str,
DBUS_TYPE_STRING, &old_state_str,
DBUS_TYPE_INVALID)) {
- perror("wpa_supplicant_dbus_notify_state_change[dbus]: "
- "not enough memory to construct state change signal.");
wpa_printf(MSG_ERROR,
- "wpa_supplicant_dbus_notify_state_change[dbus]: "
- "not enough memory to construct state change "
- "signal.");
+ "dbus: wpa_supplicant_dbus_notify_state_change: "
+ "Not enough memory to construct state change "
+ "signal");
goto out;
}
WPAS_DBUS_IFACE_INTERFACE,
"Scanning");
if (_signal == NULL) {
- perror("wpa_supplicant_dbus_notify_scanning[dbus]: couldn't "
- "create dbus signal; likely out of memory");
- wpa_printf(MSG_ERROR, "%s[dbus]: dbus control interface: not "
- "enough memory to send scan results signal.",
- __FUNCTION__);
+ wpa_printf(MSG_ERROR, "dbus: Not enough memory to send scan "
+ "results signal");
return;
}
DBUS_TYPE_INVALID)) {
dbus_connection_send(iface->con, _signal, NULL);
} else {
- perror("wpa_supplicant_dbus_notify_scanning[dbus]: not enough "
- "memory to construct signal.");
- wpa_printf(MSG_ERROR, "%s[dbus]: not enough memory to "
- "construct signal.", __FUNCTION__);
+ wpa_printf(MSG_ERROR, "dbus: Not enough memory to construct "
+ "signal");
}
dbus_message_unref(_signal);
}
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.");
+ "dbus: wpa_supplicant_dbus_notify_wps_cred: "
+ "Could not create dbus signal; likely out of "
+ "memory");
return;
}
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.");
+ "dbus: wpa_supplicant_dbus_notify_wps_cred: "
+ "Not enough memory to construct signal");
goto out;
}
if (!dbus_connection_register_object_path(iface->con,
WPAS_DBUS_PATH, &wpas_vtable,
iface)) {
- perror("dbus_connection_register_object_path[dbus]");
- wpa_printf(MSG_ERROR, "Could not set up DBus message "
- "handler.");
+ wpa_printf(MSG_ERROR, "dbus: Could not set up message "
+ "handler");
return -1;
}
case DBUS_REQUEST_NAME_REPLY_EXISTS:
case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
- perror("dbus_bus_request_name[dbus]");
- wpa_printf(MSG_ERROR, "Could not request DBus service name: "
- "already registered.");
+ wpa_printf(MSG_ERROR, "dbus: Could not request service name: "
+ "already registered");
break;
default:
- perror("dbus_bus_request_name[dbus]");
- wpa_printf(MSG_ERROR, "Could not request DBus service name: "
- "%s %s.", error.name, error.message);
+ wpa_printf(MSG_ERROR, "dbus: Could not request service name: "
+ "%s %s", error.name, error.message);
break;
}
dbus_error_free(&error);
DBusObjectPathVTable vtable = {
NULL, &wpas_iface_message_handler, NULL, NULL, NULL, NULL
};
- int ret = -1;
/* Do nothing if the control interface is not turned on */
if (ctrl_iface == NULL)
/* Register the message handler for the interface functions */
if (!dbus_connection_register_fallback(con, wpa_s->dbus_path, &vtable,
wpa_s)) {
- perror("wpas_dbus_register_iface [dbus]");
- wpa_printf(MSG_ERROR, "Could not set up DBus message "
- "handler for interface %s.", wpa_s->ifname);
- goto out;
+ wpa_printf(MSG_ERROR, "dbus: Could not set up message "
+ "handler for interface %s", wpa_s->ifname);
+ return -1;
}
- ret = 0;
-out:
- return ret;
+ return 0;
}