summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-04-16 10:59:04 -0500
committerDan Williams <dcbw@redhat.com>2015-08-07 12:40:58 -0500
commitd4559d0c54dc743dc4f37a39a2f1c6b8c46d712b (patch)
treecf0cabd4dea7d9d100b5e09a91bf2578dd068de1
parent8e435b938348be3aa710c8abc8a13e17acd737e1 (diff)
downloadNetworkManager-d4559d0c54dc743dc4f37a39a2f1c6b8c46d712b.tar.gz
wifi: make nm_ap_dump() print on one line
-rw-r--r--src/devices/wifi/nm-device-wifi.c4
-rw-r--r--src/devices/wifi/nm-wifi-ap.c52
-rw-r--r--src/devices/wifi/nm-wifi-ap.h4
3 files changed, 42 insertions, 18 deletions
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 394ed45209..e9053713f8 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -1065,7 +1065,7 @@ ap_list_dump (NMDeviceWifi *self)
nm_log_dbg (LOGD_WIFI_SCAN, "Current AP list:");
sorted = get_sorted_ap_list (self);
for (iter = sorted; iter; iter = iter->next)
- nm_ap_dump (NM_AP (iter->data), "List AP: ");
+ nm_ap_dump (NM_AP (iter->data), "List AP: ", nm_device_get_iface (NM_DEVICE (self)));
g_slist_free (sorted);
nm_log_dbg (LOGD_WIFI_SCAN, "Current AP list: done");
}
@@ -1688,7 +1688,7 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
ap = nm_ap_new_from_properties (object_path, properties);
if (ap) {
- nm_ap_dump (ap, "New AP: ");
+ nm_ap_dump (ap, "New AP: ", nm_device_get_iface (NM_DEVICE (self)));
/* Add the AP to the device's AP list */
merge_scanned_ap (self, ap, object_path, properties);
diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c
index 7fde1c70d2..4c6c0884d3 100644
--- a/src/devices/wifi/nm-wifi-ap.c
+++ b/src/devices/wifi/nm-wifi-ap.c
@@ -708,32 +708,54 @@ error:
return NULL;
}
-
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
#define MAC_ARG(x) ((guint8*)(x))[0],((guint8*)(x))[1],((guint8*)(x))[2],((guint8*)(x))[3],((guint8*)(x))[4],((guint8*)(x))[5]
+static char
+mode_to_char (NMAccessPoint *self)
+{
+ NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (self);
+
+ if (priv->mode == NM_802_11_MODE_ADHOC)
+ return '*';
+ if (priv->hotspot)
+ return '#';
+ if (priv->fake)
+ return '-';
+ return ' ';
+}
+
void
-nm_ap_dump (NMAccessPoint *ap, const char *prefix)
+nm_ap_dump (NMAccessPoint *self,
+ const char *prefix,
+ const char *ifname)
{
NMAccessPointPrivate *priv;
+ const char *supplicant_id = "-";
+ guint32 chan;
- g_return_if_fail (NM_IS_AP (ap));
+ g_return_if_fail (NM_IS_AP (self));
- priv = NM_AP_GET_PRIVATE (ap);
+ priv = NM_AP_GET_PRIVATE (self);
+ chan = nm_utils_wifi_freq_to_channel (priv->freq);
+ if (priv->supplicant_path)
+ supplicant_id = strrchr (priv->supplicant_path, '/');
- nm_log_dbg (LOGD_WIFI_SCAN, "%s'%s' (%p)",
+ nm_log_dbg (LOGD_WIFI_SCAN, "%s[" MAC_FMT "%c] %-32s[%s%u %s%u%% %c W:%04X R:%04X] [%3u] %s%s",
prefix,
+ MAC_ARG (priv->address.ether_addr_octet),
+ mode_to_char (self),
priv->ssid ? nm_utils_escape_ssid (priv->ssid->data, priv->ssid->len) : "(none)",
- ap);
- nm_log_dbg (LOGD_WIFI_SCAN, " BSSID " MAC_FMT, MAC_ARG (priv->address.ether_addr_octet));
- 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);
- nm_log_dbg (LOGD_WIFI_SCAN, " rsn flags 0x%X", priv->rsn_flags);
- nm_log_dbg (LOGD_WIFI_SCAN, " quality %d", priv->strength);
- nm_log_dbg (LOGD_WIFI_SCAN, " frequency %d", priv->freq);
- nm_log_dbg (LOGD_WIFI_SCAN, " max rate %d", priv->max_bitrate);
- nm_log_dbg (LOGD_WIFI_SCAN, " last-seen %d", (int) priv->last_seen);
+ chan > 99 ? "" : (chan > 9 ? " " : " "),
+ chan,
+ priv->strength < 100 ? " " : "",
+ priv->strength,
+ priv->flags & NM_802_11_AP_FLAGS_PRIVACY ? 'P' : ' ',
+ priv->wpa_flags & 0xFFFF,
+ priv->rsn_flags & 0xFFFF,
+ nm_utils_get_monotonic_timestamp_s () - priv->last_seen,
+ ifname,
+ supplicant_id);
}
const char *
diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h
index d28dc93669..5519208532 100644
--- a/src/devices/wifi/nm-wifi-ap.h
+++ b/src/devices/wifi/nm-wifi-ap.h
@@ -117,6 +117,8 @@ gboolean nm_ap_complete_connection (NMAccessPoint *self,
NMAccessPoint * nm_ap_match_in_hash (NMAccessPoint *find_ap, GHashTable *hash);
-void nm_ap_dump (NMAccessPoint *ap, const char *prefix);
+void nm_ap_dump (NMAccessPoint *self,
+ const char *prefix,
+ const char *ifname);
#endif /* NM_ACCESS_POINT_H */