mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-09 15:30:27 +01:00
wifi: drop Wext handlers get_rate()/get_bssid()/get_qual() from NMWifiUtilsClass
Wext is anyway deprected. Our NMWifiUtilsClass should not have API to accomodate it. That means, we don't need dedicated get_rate(), get_bssid(), get_qual() hooks, when they all are only called by get_station(). Instead, push the Wext specific code down.
This commit is contained in:
parent
54817e3cfd
commit
07a60e859c
3 changed files with 31 additions and 39 deletions
|
|
@ -31,16 +31,6 @@ typedef struct {
|
|||
/* Return first supported frequency in the zero-terminated list */
|
||||
guint32 (*find_freq)(NMWifiUtils *data, const guint32 *freqs);
|
||||
|
||||
/* Return current bitrate in Kbps */
|
||||
guint32 (*get_rate)(NMWifiUtils *data);
|
||||
|
||||
gboolean (*get_bssid)(NMWifiUtils *data, guint8 *out_bssid);
|
||||
|
||||
/* Return a signal strength percentage 0 - 100% for the current BSSID;
|
||||
* return -1 on errors or if not associated.
|
||||
*/
|
||||
int (*get_qual)(NMWifiUtils *data);
|
||||
|
||||
/*
|
||||
* @out_bssid: must be NULL or an ETH_ALEN-byte buffer
|
||||
* @out_quality: receives signal strength percentage 0 - 100% for the current BSSID, if not NULL
|
||||
|
|
|
|||
|
|
@ -453,6 +453,35 @@ wifi_wext_get_qual(NMWifiUtils *data)
|
|||
return wext_qual_to_percent(&stats.qual, &wext->max_qual);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
wifi_wext_get_station(NMWifiUtils *data, guint8 *out_bssid, int *out_quality, guint32 *out_rate)
|
||||
{
|
||||
NMEtherAddr local_addr;
|
||||
|
||||
if (!out_bssid && !out_quality && !out_rate) {
|
||||
/* hm, the caller requested no parameter at all?
|
||||
* Don't simply return TRUE, but at least check that
|
||||
* we can successfully fetch the bssid. */
|
||||
out_bssid = local_addr.ether_addr_octet;
|
||||
}
|
||||
|
||||
if (out_bssid) {
|
||||
if (!wifi_wext_get_bssid(data, out_bssid))
|
||||
return FALSE;
|
||||
}
|
||||
if (out_quality) {
|
||||
*out_quality = wifi_wext_get_qual(data);
|
||||
if (*out_quality < 0)
|
||||
return FALSE;
|
||||
}
|
||||
if (out_rate) {
|
||||
*out_rate = wifi_wext_get_rate(data);
|
||||
if (*out_rate == 0)
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* OLPC Mesh-only functions */
|
||||
|
||||
|
|
@ -677,9 +706,7 @@ nm_wifi_utils_wext_class_init(NMWifiUtilsWextClass *klass)
|
|||
wifi_utils_class->set_powersave = wifi_wext_set_powersave;
|
||||
wifi_utils_class->get_freq = wifi_wext_get_freq;
|
||||
wifi_utils_class->find_freq = wifi_wext_find_freq;
|
||||
wifi_utils_class->get_bssid = wifi_wext_get_bssid;
|
||||
wifi_utils_class->get_rate = wifi_wext_get_rate;
|
||||
wifi_utils_class->get_qual = wifi_wext_get_qual;
|
||||
wifi_utils_class->get_station = wifi_wext_get_station;
|
||||
wifi_utils_class->get_mesh_channel = wifi_wext_get_mesh_channel;
|
||||
wifi_utils_class->set_mesh_channel = wifi_wext_set_mesh_channel;
|
||||
wifi_utils_class->set_mesh_ssid = wifi_wext_set_mesh_ssid;
|
||||
|
|
|
|||
|
|
@ -134,34 +134,9 @@ nm_wifi_utils_find_freq(NMWifiUtils *data, const guint32 *freqs)
|
|||
gboolean
|
||||
nm_wifi_utils_get_station(NMWifiUtils *data, guint8 *out_bssid, int *out_quality, guint32 *out_rate)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail(data != NULL, FALSE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS(data);
|
||||
|
||||
if (klass->get_station != NULL)
|
||||
return klass->get_station(data, out_bssid, out_quality, out_rate);
|
||||
|
||||
if (out_bssid) {
|
||||
memset(out_bssid, 0, ETH_ALEN);
|
||||
if (!klass->get_bssid(data, out_bssid))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (out_quality) {
|
||||
*out_quality = klass->get_qual(data);
|
||||
if (*out_quality < 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (out_rate) {
|
||||
*out_rate = klass->get_rate(data);
|
||||
if (*out_rate == 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return NM_WIFI_UTILS_GET_CLASS(data)->get_station(data, out_bssid, out_quality, out_rate);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue