コード例 #1
0
ファイル: ctrl_iface_dbus.c プロジェクト: ebichu/dd-wrt
/**
 * wpas_dispatch_bssid_method - dispatch messages for scanned networks
 * @message: the incoming dbus message
 * @wpa_s: a network interface's data
 * @bssid: bssid of the scanned network we're interested in
 * Returns: a reply dbus message, or a dbus error message
 *
 * This function dispatches all incoming dbus messages for scanned networks.
 */
static DBusMessage * wpas_dispatch_bssid_method(DBusMessage *message,
						struct wpa_supplicant *wpa_s,
						const char *bssid)
{
	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;
	}

	/* 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 (!res) {
		reply = wpas_dbus_new_invalid_bssid_error(message);
		goto out;
	}

	/* Dispatch the method call against the scanned bssid */
	if (!strcmp(method, "properties"))
		reply = wpas_dbus_bssid_properties(message, wpa_s, res);

out:
	return reply;
}
コード例 #2
0
/**
 * wpas_dispatch_bssid_method - dispatch messages for scanned networks
 * @message: the incoming dbus message
 * @wpa_s: a network interface's data
 * @bssid: bssid of the scanned network we're interested in
 * Returns: a reply dbus message, or a dbus error message
 *
 * This function dispatches all incoming dbus messages for scanned networks.
 */
static DBusMessage * wpas_dispatch_bssid_method(DBusMessage *message,
						struct wpa_supplicant *wpa_s,
						const char *bssid_txt)
{
	u8 bssid[ETH_ALEN];
	struct wpa_bss *bss;

	if (hexstr2bin(bssid_txt, bssid, ETH_ALEN) < 0)
		return wpas_dbus_new_invalid_bssid_error(message);

	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 (os_strcmp(dbus_message_get_member(message), "properties") == 0)
		return wpas_dbus_bssid_properties(message, wpa_s, bss);

	return NULL;
}