merge: wifi bssid handling fixes

Avoid passing NULL bssid where it does not make sense, fix a couple of bad
asserts.

https://bugzilla.gnome.org/show_bug.cgi?id=739258
This commit is contained in:
Lubomir Rintel 2014-11-13 16:42:45 +01:00
commit 46c869b295
2 changed files with 10 additions and 13 deletions

View file

@ -395,7 +395,7 @@ find_active_ap (NMDeviceWifi *self,
ap_ssid ? "'" : "",
ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)",
ap_ssid ? "'" : "",
ap_bssid);
str_if_set (ap_bssid, "(none)"));
if (ap == ignore_ap) {
_LOGD (LOGD_WIFI, " ignored");
@ -460,14 +460,13 @@ find_active_ap (NMDeviceWifi *self,
* we can't match the AP based on frequency at all, just give up.
*/
if (match_nofreq && ((found_a_band != found_bg_band) || (devfreq == 0))) {
const char *ap_bssid = nm_ap_get_address (match_nofreq);
const GByteArray *ap_ssid = nm_ap_get_ssid (match_nofreq);
_LOGD (LOGD_WIFI, " matched %s%s%s %s",
ap_ssid ? "'" : "",
ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)",
ap_ssid ? "'" : "",
ap_bssid);
str_if_set (nm_ap_get_address (match_nofreq), "(none)"));
active_ap = match_nofreq;
goto done;
@ -1699,12 +1698,12 @@ merge_scanned_ap (NMDeviceWifi *self,
if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) {
/* Yay, matched it, no longer treat as hidden */
_LOGD (LOGD_WIFI_SCAN, "matched hidden AP %s => '%s'",
bssid, nm_utils_escape_ssid (ssid->data, ssid->len));
str_if_set (bssid, "(none)"), nm_utils_escape_ssid (ssid->data, ssid->len));
nm_ap_set_broadcast (merge_ap, FALSE);
} else {
/* Didn't have an entry for this AP in the database */
_LOGD (LOGD_WIFI_SCAN, "failed to match hidden AP %s",
bssid);
str_if_set (bssid, "(none)"));
}
}
@ -1723,7 +1722,7 @@ merge_scanned_ap (NMDeviceWifi *self,
if (found_ap) {
_LOGD (LOGD_WIFI_SCAN, "merging AP '%s' %s (%p) with existing (%p)",
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
bssid,
str_if_set (bssid, "(none)"),
merge_ap,
found_ap);
@ -1745,7 +1744,7 @@ merge_scanned_ap (NMDeviceWifi *self,
/* New entry in the list */
_LOGD (LOGD_WIFI_SCAN, "adding new AP '%s' %s (%p)",
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
bssid, merge_ap);
str_if_set (bssid, "(none)"), merge_ap);
g_object_ref (merge_ap);
priv->ap_list = g_slist_prepend (priv->ap_list, merge_ap);
@ -1801,14 +1800,12 @@ cull_scan_list (NMDeviceWifi *self)
/* Remove outdated APs */
for (elt = outdated_list; elt; elt = g_slist_next (elt)) {
NMAccessPoint *outdated_ap = NM_AP (elt->data);
const char *bssid;
const GByteArray *ssid;
bssid = nm_ap_get_address (outdated_ap);
ssid = nm_ap_get_ssid (outdated_ap);
_LOGD (LOGD_WIFI_SCAN,
" removing %s (%s%s%s)",
bssid,
str_if_set (nm_ap_get_address (outdated_ap), "(none)"),
ssid ? "'" : "",
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
ssid ? "'" : "");
@ -3015,7 +3012,7 @@ activation_success_handler (NMDevice *device)
* the BSSID off the card and fill in the BSSID of the activation AP.
*/
nm_platform_wifi_get_bssid (ifindex, bssid);
if (!nm_ethernet_address_is_valid (nm_ap_get_address (ap), -1)) {
if (!nm_ap_get_address (ap)) {
char *bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
nm_ap_set_address (ap, bssid_str);
g_free (bssid_str);

View file

@ -725,7 +725,7 @@ nm_ap_dump (NMAccessPoint *ap, const char *prefix)
prefix,
priv->ssid ? nm_utils_escape_ssid (priv->ssid->data, priv->ssid->len) : "(none)",
ap);
nm_log_dbg (LOGD_WIFI_SCAN, " BSSID %s", priv->address);
nm_log_dbg (LOGD_WIFI_SCAN, " BSSID %s", str_if_set (priv->address, "(none)"));
nm_log_dbg (LOGD_WIFI_SCAN, " mode %d", priv->mode);
nm_log_dbg (LOGD_WIFI_SCAN, " flags 0x%X", priv->flags);
nm_log_dbg (LOGD_WIFI_SCAN, " wpa flags 0x%X", priv->wpa_flags);
@ -1129,7 +1129,7 @@ nm_ap_check_compatible (NMAccessPoint *self,
return FALSE;
bssid = nm_setting_wireless_get_bssid (s_wireless);
if (bssid && !nm_utils_hwaddr_matches (bssid, -1, priv->address, -1))
if (bssid && (!priv->address || !nm_utils_hwaddr_matches (bssid, -1, priv->address, -1)))
return FALSE;
mode = nm_setting_wireless_get_mode (s_wireless);