mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-01 07:58:02 +02:00
wifi: Switch to using nm_platform_wifi_get_station
Switch NMDeviceIwd and NMDeviceWifi from nm_platform_wifi_get_bssid, nm_platform_wifi_get_quality and nm_platform_wifi_get_rate to nm_platform_wifi_get_station. I also dropped the checks for the signal quality percentage range as they're no longer necessary and in NMDeviceWifi dropped zero-initialization of the bssid buffer before the nm_platform_wifi_get_bssid call which not necessary either.
This commit is contained in:
parent
e5a2520069
commit
27eba49691
2 changed files with 45 additions and 40 deletions
|
|
@ -433,26 +433,26 @@ periodic_update(NMDeviceIwd *self)
|
|||
|
||||
platform = nm_device_get_platform(NM_DEVICE(self));
|
||||
|
||||
/* TODO: obtain this through the net.connman.iwd.SignalLevelAgent API.
|
||||
* For now we're waking up for the rate updates anyway.
|
||||
/* TODO: obtain quality through the net.connman.iwd.SignalLevelAgent API.
|
||||
* For now we're waking up for the rate/BSSID updates anyway.
|
||||
*/
|
||||
percent = nm_platform_wifi_get_quality(platform, ifindex);
|
||||
if (percent >= 0 && percent <= 100) {
|
||||
if (nm_wifi_ap_set_strength(priv->current_ap, (gint8) percent)) {
|
||||
#if NM_MORE_LOGGING
|
||||
ap_changed = TRUE;
|
||||
#endif
|
||||
}
|
||||
if (!nm_platform_wifi_get_station(platform, ifindex, bssid, &percent, &new_rate)) {
|
||||
_LOGD(LOGD_WIFI, "BSSID / quality / rate platform query failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nm_wifi_ap_set_strength(priv->current_ap, (gint8) percent)) {
|
||||
#if NM_MORE_LOGGING
|
||||
ap_changed = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
new_rate = nm_platform_wifi_get_rate(platform, ifindex);
|
||||
if (new_rate != priv->rate) {
|
||||
priv->rate = new_rate;
|
||||
_notify(self, PROP_BITRATE);
|
||||
}
|
||||
|
||||
if (nm_platform_wifi_get_bssid(platform, ifindex, bssid)
|
||||
&& nm_ethernet_address_is_valid(bssid, ETH_ALEN)
|
||||
if (nm_ethernet_address_is_valid(bssid, ETH_ALEN)
|
||||
&& memcmp(bssid, priv->current_ap_bssid, ETH_ALEN)) {
|
||||
gs_free char *bssid_str = NULL;
|
||||
memcpy(priv->current_ap_bssid, bssid, ETH_ALEN);
|
||||
|
|
|
|||
|
|
@ -728,6 +728,7 @@ periodic_update(NMDeviceWifi *self)
|
|||
NMDeviceWifiPrivate *priv;
|
||||
int ifindex;
|
||||
guint32 new_rate;
|
||||
int percent;
|
||||
|
||||
if (nm_device_get_state(NM_DEVICE(self)) != NM_DEVICE_STATE_ACTIVATED) {
|
||||
/* BSSID and signal strength have meaningful values only if the device
|
||||
|
|
@ -757,23 +758,22 @@ periodic_update(NMDeviceWifi *self)
|
|||
if (ifindex <= 0)
|
||||
g_return_if_reached();
|
||||
|
||||
if (priv->current_ap) {
|
||||
int percent;
|
||||
|
||||
percent = nm_platform_wifi_get_quality(nm_device_get_platform(NM_DEVICE(self)), ifindex);
|
||||
if (percent >= 0 && percent <= 100) {
|
||||
if (nm_wifi_ap_set_strength(priv->current_ap, (gint8) percent)) {
|
||||
if (priv->current_ap
|
||||
&& nm_platform_wifi_get_station(nm_device_get_platform(NM_DEVICE(self)),
|
||||
ifindex,
|
||||
NULL,
|
||||
&percent,
|
||||
&new_rate)) {
|
||||
if (nm_wifi_ap_set_strength(priv->current_ap, (gint8) percent)) {
|
||||
#if NM_MORE_LOGGING
|
||||
_ap_dump(self, LOGL_TRACE, priv->current_ap, "updated", 0);
|
||||
_ap_dump(self, LOGL_TRACE, priv->current_ap, "updated", 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new_rate = nm_platform_wifi_get_rate(nm_device_get_platform(NM_DEVICE(self)), ifindex);
|
||||
if (new_rate != priv->rate) {
|
||||
priv->rate = new_rate;
|
||||
_notify(self, PROP_BITRATE);
|
||||
if (new_rate != priv->rate) {
|
||||
priv->rate = new_rate;
|
||||
_notify(self, PROP_BITRATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3369,31 +3369,36 @@ activation_success_handler(NMDevice *device)
|
|||
g_warn_if_fail(priv->current_ap);
|
||||
if (priv->current_ap) {
|
||||
if (nm_wifi_ap_get_fake(priv->current_ap)) {
|
||||
gboolean ap_changed = FALSE;
|
||||
gboolean ap_changed = FALSE;
|
||||
gboolean update_bssid = !nm_wifi_ap_get_address(priv->current_ap);
|
||||
gboolean update_rate = !nm_wifi_ap_get_max_bitrate(priv->current_ap);
|
||||
guint8 bssid[ETH_ALEN];
|
||||
guint32 rate;
|
||||
|
||||
/* If the activation AP hasn't been seen by the supplicant in a scan
|
||||
* yet, it will be "fake". This usually happens for Ad-Hoc and
|
||||
* AP-mode connections. Fill in the details from the device itself
|
||||
* until the supplicant sends the scan result.
|
||||
*/
|
||||
if (!nm_wifi_ap_get_address(priv->current_ap)) {
|
||||
guint8 bssid[ETH_ALEN] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
||||
gs_free char *bssid_str = NULL;
|
||||
|
||||
if (nm_platform_wifi_get_bssid(nm_device_get_platform(device), ifindex, bssid)
|
||||
&& nm_ethernet_address_is_valid(bssid, ETH_ALEN)) {
|
||||
bssid_str = nm_utils_hwaddr_ntoa(bssid, ETH_ALEN);
|
||||
ap_changed |= nm_wifi_ap_set_address(priv->current_ap, bssid_str);
|
||||
}
|
||||
}
|
||||
if (!nm_wifi_ap_get_freq(priv->current_ap))
|
||||
ap_changed |= nm_wifi_ap_set_freq(
|
||||
priv->current_ap,
|
||||
nm_platform_wifi_get_frequency(nm_device_get_platform(device), ifindex));
|
||||
if (!nm_wifi_ap_get_max_bitrate(priv->current_ap))
|
||||
ap_changed |= nm_wifi_ap_set_max_bitrate(
|
||||
priv->current_ap,
|
||||
nm_platform_wifi_get_rate(nm_device_get_platform(device), ifindex));
|
||||
|
||||
if ((update_bssid || update_rate)
|
||||
&& nm_platform_wifi_get_station(nm_device_get_platform(device),
|
||||
ifindex,
|
||||
update_bssid ? bssid : NULL,
|
||||
NULL,
|
||||
update_rate ? &rate : NULL)) {
|
||||
if (update_bssid && nm_ethernet_address_is_valid(bssid, ETH_ALEN)) {
|
||||
gs_free char *bssid_str = NULL;
|
||||
bssid_str = nm_utils_hwaddr_ntoa(bssid, ETH_ALEN);
|
||||
ap_changed |= nm_wifi_ap_set_address(priv->current_ap, bssid_str);
|
||||
}
|
||||
if (update_rate)
|
||||
ap_changed |= nm_wifi_ap_set_max_bitrate(priv->current_ap, rate);
|
||||
}
|
||||
|
||||
if (ap_changed)
|
||||
_ap_dump(self, LOGL_DEBUG, priv->current_ap, "updated", 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue