dbus: Replace BSS 'Properties' property with separate properties

In addition, remove Quality and Noise properties since the BSS table
is not the correct place for fetching per-channel information (Noise)
and Quality is not well-defined (nor available from many drivers).
This commit is contained in:
Witold Sowa 2010-01-01 12:28:24 +02:00 committed by Jouni Malinen
parent 21e210fc99
commit 58605c6e61
4 changed files with 352 additions and 99 deletions

View file

@ -600,22 +600,44 @@ scan results.
<ul> <ul>
<li> <li>
<h3>Properties - a{sv} - (read)</h3> <h3>BSSID - ay - (read)</h3>
<p>Properties of scanned BSS. Dictionary contains following entries:</p> <p>BSSID of the BSS.</p>
<table> </li>
<tr><th>Key</th><th>Value type</th> <li>
<tr><td>BSSID</td><td>ay</td> <h3>SSID - ay - (read)</h3>
<tr><td>SSID</td><td>ay</td> <p>SSID of the BSS.</p>
<tr><td>WPAIE</td><td>ay</td> </li>
<tr><td>RSNIE</td><td>ay</td> <li>
<tr><td>WPSIE</td><td>ay</td> <h3>WPAIE - ay - (read)</h3>
<tr><td>Frequency</td><td>i</td> <p>WPA information element of the BSS. The second byte contain number of bytes following it.</p>
<tr><td>Capabilities</td><td>q</td> </li>
<tr><td>Quality</td><td>i</td> <li>
<tr><td>Noise</td><td>i</td> <h3>RSNIE - ay - (read)</h3>
<tr><td>Level</td><td>i</td> <p>RSN information element of the BSS. The second byte contain number of bytes following it.</p>
<tr><td>MaxRate</td><td>i</td> </li>
</table> <li>
<h3>WPSIE - ay - (read)</h3>
<p>WPS information element of the BSS. The second byte contain number of bytes following it.</p>
</li>
<li>
<h3>Privacy - b - (read)</h3>
<p>Indicates if BSS supports privacy.</p>
</li>
<li>
<h3>Mode - s - (read)</h3>
<p>Describes mode of the BSS. Possible values are: "ad-hoc" and "infrastructure".</p>
</li>
<li>
<h3>Frequency - q - (read)</h3>
<p>Frequency of the BSS in MHz.</p>
</li>
<li>
<h3>MaxRate - q - (read)</h3>
<p>Maximal data rate of the BSS in bits per second.</p>
</li>
<li>
<h3>Signal - n - (read)</h3>
<p>Signal strength of the BSS.</p>
</li> </li>
</ul> </ul>

View file

@ -1247,8 +1247,53 @@ static int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
static const struct wpas_dbus_property wpas_dbus_bss_properties[] = { static const struct wpas_dbus_property wpas_dbus_bss_properties[] = {
{ "Properties", WPAS_DBUS_NEW_IFACE_BSSID, "a{sv}", { "SSID", WPAS_DBUS_NEW_IFACE_BSSID, "ay",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_properties, (WPADBusPropertyAccessor) wpas_dbus_getter_bss_ssid,
NULL,
R
},
{ "BSSID", WPAS_DBUS_NEW_IFACE_BSSID, "ay",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_bssid,
NULL,
R
},
{ "Privacy", WPAS_DBUS_NEW_IFACE_BSSID, "b",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_privacy,
NULL,
R
},
{ "Mode", WPAS_DBUS_NEW_IFACE_BSSID, "s",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_mode,
NULL,
R
},
{ "Signal", WPAS_DBUS_NEW_IFACE_BSSID, "n",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_signal,
NULL,
R
},
{ "Frequency", WPAS_DBUS_NEW_IFACE_BSSID, "q",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_frequency,
NULL,
R
},
{ "MaxRate", WPAS_DBUS_NEW_IFACE_BSSID, "q",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_max_rate,
NULL,
R
},
{ "WPAIE", WPAS_DBUS_NEW_IFACE_BSSID, "ay",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_wpaie,
NULL,
R
},
{ "RSNIE", WPAS_DBUS_NEW_IFACE_BSSID, "ay",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_rsnie,
NULL,
R
},
{ "WPSIE", WPAS_DBUS_NEW_IFACE_BSSID, "ay",
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_wpsie,
NULL, NULL,
R R
}, },

View file

@ -2562,109 +2562,268 @@ out:
/** /**
* wpas_dbus_getter_bss_properties - Return the properties of a scanned bss * wpas_dbus_getter_bss_bssid - Return the BSSID of a BSS
* @message: Pointer to incoming dbus message * @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss' bssid * @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the properties for the requested bss * Returns: a dbus message containing the bssid for the requested bss
* *
* Getter for "Properties" property. * Getter for "BSSID" property.
*/ */
DBusMessage * wpas_dbus_getter_bss_properties(DBusMessage *message, DBusMessage * wpas_dbus_getter_bss_bssid(DBusMessage *message,
struct bss_handler_args *bss) struct bss_handler_args *bss)
{ {
DBusMessage *reply = NULL;
DBusMessageIter iter, iter_dict, variant_iter;
const u8 *ie;
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id); struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
if (res == NULL) if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_bssid[dbus]: no "
"bss with id %d found", bss->id);
return NULL; return NULL;
}
/* Dump the properties into a dbus message */ return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
if (message == NULL) res->bssid, ETH_ALEN);
reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL); }
/**
* wpas_dbus_getter_bss_ssid - Return the SSID of a BSS
* @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the ssid for the requested bss
*
* Getter for "SSID" property.
*/
DBusMessage * wpas_dbus_getter_bss_ssid(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_ssid[dbus]: no "
"bss with id %d found", bss->id);
return NULL;
}
return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
res->ssid,
res->ssid_len);
}
/**
* wpas_dbus_getter_bss_privacy - Return the privacy flag of a BSS
* @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the privacy flag value of requested bss
*
* Getter for "Privacy" property.
*/
DBusMessage * wpas_dbus_getter_bss_privacy(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
dbus_bool_t privacy;
if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_privacy[dbus]: no "
"bss with id %d found", bss->id);
return NULL;
}
privacy = res->caps && IEEE80211_CAP_PRIVACY ? TRUE : FALSE;
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_BOOLEAN,
&privacy);
}
/**
* wpas_dbus_getter_bss_mode - Return the mode of a BSS
* @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the mode of requested bss
*
* Getter for "Mode" property.
*/
DBusMessage * wpas_dbus_getter_bss_mode(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
const char *mode;
if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_mode[dbus]: no "
"bss with id %d found", bss->id);
return NULL;
}
if (res->caps & IEEE80211_CAP_IBSS)
mode = "ad-hoc";
else else
reply = dbus_message_new_method_return(message); mode = "infrastructure";
if (!reply) return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
goto error; &mode);
}
dbus_message_iter_init_append(reply, &iter);
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, /**
"a{sv}", &variant_iter)) * wpas_dbus_getter_bss_level - Return the signal strength of a BSS
goto error; * @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the signal strength of requested bss
*
* Getter for "Level" property.
*/
DBusMessage * wpas_dbus_getter_bss_signal(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
if (!wpa_dbus_dict_open_write(&variant_iter, &iter_dict)) if (!res) {
goto error; wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_signal[dbus]: no "
"bss with id %d found", bss->id);
return NULL;
}
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "BSSID", return wpas_dbus_simple_property_getter(message, DBUS_TYPE_INT16,
(const char *) res->bssid, &res->level);
ETH_ALEN)) }
goto error;
ie = wpa_bss_get_ie(res, WLAN_EID_SSID);
if (ie) { /**
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "SSID", * wpas_dbus_getter_bss_frequency - Return the frequency of a BSS
(const char *) (ie + 2), * @message: Pointer to incoming dbus message
ie[1])) * @bss: a pair of interface describing structure and bss's id
goto error; * Returns: a dbus message containing the frequency of requested bss
*
* Getter for "Frequency" property.
*/
DBusMessage * wpas_dbus_getter_bss_frequency(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_frequency[dbus]: "
"no bss with id %d found", bss->id);
return NULL;
}
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_UINT16,
&res->freq);
}
/**
* wpas_dbus_getter_bss_max_rate - Return the maximal rate of a BSS
* @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the maximal data rate of requested bss
*
* Getter for "MaxRate" property.
*/
DBusMessage * wpas_dbus_getter_bss_max_rate(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
int max_rate;
if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_max_rate[dbus]: "
"no bss with id %d found", bss->id);
return NULL;
}
max_rate = wpa_bss_get_max_rate(res);
return wpas_dbus_simple_property_getter(message, DBUS_TYPE_UINT16,
&max_rate);
}
/**
* wpas_dbus_getter_bss_wpaie - Return the WPA IE of a BSS
* @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the WPA information elements
* of requested bss
*
* Getter for "WPAIE" property.
*/
DBusMessage * wpas_dbus_getter_bss_wpaie(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
const u8 *ie;
if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_wpaie[dbus]: no "
"bss with id %d found", bss->id);
return NULL;
} }
ie = wpa_bss_get_vendor_ie(res, WPA_IE_VENDOR_TYPE); ie = wpa_bss_get_vendor_ie(res, WPA_IE_VENDOR_TYPE);
if (ie) { if (!ie)
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "WPAIE", return NULL;
(const char *) ie, return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
ie[1] + 2)) ie, ie[1] + 2);
goto error; }
/**
* wpas_dbus_getter_bss_rsnie - Return the RSN IE of a BSS
* @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the RSN information elements
* of requested bss
*
* Getter for "RSNIE" property.
*/
DBusMessage * wpas_dbus_getter_bss_rsnie(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
const u8 *ie;
if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_rsnie[dbus]: no "
"bss with id %d found", bss->id);
return NULL;
} }
ie = wpa_bss_get_ie(res, WLAN_EID_RSN); ie = wpa_bss_get_ie(res, WLAN_EID_RSN);
if (ie) { if (!ie)
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "RSNIE", return NULL;
(const char *) ie, return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
ie[1] + 2)) ie, ie[1] + 2);
goto error; }
/**
* wpas_dbus_getter_bss_wpsie - Return the WPS IE of a BSS
* @message: Pointer to incoming dbus message
* @bss: a pair of interface describing structure and bss's id
* Returns: a dbus message containing the WPS information elements
* of requested bss
*
* Getter for "WPSIE" property.
*/
DBusMessage * wpas_dbus_getter_bss_wpsie(DBusMessage *message,
struct bss_handler_args *bss)
{
struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
const u8 *ie;
if (!res) {
wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_wpsie[dbus]: no "
"bss with id %d found", bss->id);
return NULL;
} }
ie = wpa_bss_get_vendor_ie(res, WPS_IE_VENDOR_TYPE); ie = wpa_bss_get_vendor_ie(res, WPS_IE_VENDOR_TYPE);
if (ie) { if (!ie)
if (!wpa_dbus_dict_append_byte_array(&iter_dict, "WPSIE", return NULL;
(const char *) ie, return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
ie[1] + 2)) ie, ie[1] + 2);
goto error;
}
if (res->freq) {
if (!wpa_dbus_dict_append_int32(&iter_dict, "Frequency",
res->freq))
goto error;
}
if (!wpa_dbus_dict_append_uint16(&iter_dict, "Capabilities",
res->caps))
goto error;
if (!(res->flags & WPA_SCAN_QUAL_INVALID) &&
!wpa_dbus_dict_append_int32(&iter_dict, "Quality", res->qual))
goto error;
if (!(res->flags & WPA_SCAN_NOISE_INVALID) &&
!wpa_dbus_dict_append_int32(&iter_dict, "Noise", res->noise))
goto error;
if (!(res->flags & WPA_SCAN_LEVEL_INVALID) &&
!wpa_dbus_dict_append_int32(&iter_dict, "Level", res->level))
goto error;
if (!wpa_dbus_dict_append_int32(&iter_dict, "MaxRate",
wpa_bss_get_max_rate(res) * 500000))
goto error;
if (!wpa_dbus_dict_close_write(&iter, &iter_dict))
goto error;
return reply;
error:
if (reply)
dbus_message_unref(reply);
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
} }

View file

@ -121,8 +121,35 @@ DBusMessage * wpas_dbus_getter_networks(DBusMessage *message,
DBusMessage * wpas_dbus_getter_blobs(DBusMessage *message, DBusMessage * wpas_dbus_getter_blobs(DBusMessage *message,
struct wpa_supplicant *bss); struct wpa_supplicant *bss);
DBusMessage * wpas_dbus_getter_bss_properties(DBusMessage *message, DBusMessage * wpas_dbus_getter_bss_bssid(DBusMessage *message,
struct bss_handler_args *bss); struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_ssid(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_privacy(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_mode(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_signal(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_frequency(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_max_rate(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_wpaie(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_rsnie(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_bss_wpsie(DBusMessage *message,
struct bss_handler_args *bss);
DBusMessage * wpas_dbus_getter_enabled(DBusMessage *message, DBusMessage * wpas_dbus_getter_enabled(DBusMessage *message,
struct network_handler_args *net); struct network_handler_args *net);