summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-06-15 13:57:30 +0200
committerThomas Haller <thaller@redhat.com>2018-06-15 16:23:30 +0200
commit07fd0502f68a1116ee4cfdb31b24b422b142847f (patch)
tree8a41f61869af658b60c09b25f2b8eeee5f0950e5
parent1c0aa397b372cf6cccaacd11546cc99011090d35 (diff)
wifi: expose LastScan as milliseconds not seconds
This doesn't wrap around in 68 years of uptime and is consistent with o.fd.NM.Checkpoint.Created.
-rw-r--r--clients/cli/devices.c2
-rw-r--r--introspection/org.freedesktop.NetworkManager.Device.Wireless.xml4
-rw-r--r--libnm/nm-device-wifi.c20
-rw-r--r--libnm/nm-device-wifi.h4
-rw-r--r--shared/nm-utils/nm-shared-utils.h5
-rw-r--r--src/devices/wifi/nm-device-iwd.c18
-rw-r--r--src/devices/wifi/nm-device-wifi.c30
-rw-r--r--src/devices/wifi/nm-wifi-common.c2
-rw-r--r--src/supplicant/nm-supplicant-interface.c16
-rw-r--r--src/supplicant/nm-supplicant-interface.h2
-rwxr-xr-xtools/test-networkmanager-service.py2
11 files changed, 53 insertions, 52 deletions
diff --git a/clients/cli/devices.c b/clients/cli/devices.c
index d92978f5a6..235690980f 100644
--- a/clients/cli/devices.c
+++ b/clients/cli/devices.c
@@ -2770,7 +2770,7 @@ wifi_list_aps (NMDeviceWifi *wifi,
gboolean needs_rescan;
WifiListData *data;
- needs_rescan = rescan_cutoff < 0 || (rescan_cutoff > 0 && nm_device_wifi_get_last_scan (wifi) < rescan_cutoff);
+ needs_rescan = rescan_cutoff < 0 || (rescan_cutoff > 0 && nm_device_wifi_get_last_scan (wifi) < (rescan_cutoff * 1000));
if (needs_rescan) {
data = g_slice_new0 (WifiListData);
diff --git a/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml b/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml
index af6e8c7ff3..130385455c 100644
--- a/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml
+++ b/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml
@@ -99,12 +99,12 @@
<!--
LastScan:
- The timestamp (in CLOCK_BOOTTIME seconds) for the last finished network scan.
+ The timestamp (in CLOCK_BOOTTIME milliseconds) for the last finished network scan.
A value of -1 means the device never scanned for access points.
Since: 1.12
-->
- <property name="LastScan" type="i" access="read"/>
+ <property name="LastScan" type="x" access="read"/>
<!--
PropertiesChanged:
diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c
index 851983f46c..1d6e51064c 100644
--- a/libnm/nm-device-wifi.c
+++ b/libnm/nm-device-wifi.c
@@ -59,7 +59,7 @@ typedef struct {
NMAccessPoint *active_ap;
NMDeviceWifiCapabilities wireless_caps;
GPtrArray *aps;
- gint last_scan;
+ gint64 last_scan;
RequestScanInfo *scan_info;
} NMDeviceWifiPrivate;
@@ -273,19 +273,19 @@ nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device,
* nm_device_wifi_get_last_scan:
* @device: a #NMDeviceWifi
*
- * Returns the timestamp (in CLOCK_BOOTTIME seconds) for the last finished
+ * Returns the timestamp (in CLOCK_BOOTTIME milliseconds) for the last finished
* network scan. A value of -1 means the device never scanned for access points.
*
* Returns: the last scan time in seconds
*
* Since: 1.12
**/
-gint
+gint64
nm_device_wifi_get_last_scan (NMDeviceWifi *device)
{
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), -1);
+ g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), -1);
- return NM_DEVICE_WIFI_GET_PRIVATE (device)->last_scan;
+ return NM_DEVICE_WIFI_GET_PRIVATE (device)->last_scan;
}
static GVariant *
@@ -721,7 +721,7 @@ get_property (GObject *object,
g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_wifi_get_access_points (self)));
break;
case PROP_LAST_SCAN:
- g_value_set_int (value, nm_device_wifi_get_last_scan (self));
+ g_value_set_int64 (value, nm_device_wifi_get_last_scan (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -935,10 +935,10 @@ nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class)
**/
g_object_class_install_property
(object_class, PROP_LAST_SCAN,
- g_param_spec_int (NM_DEVICE_WIFI_LAST_SCAN, "", "",
- -1, G_MAXINT, -1,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ g_param_spec_int64 (NM_DEVICE_WIFI_LAST_SCAN, "", "",
+ -1, G_MAXINT64, -1,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/* signals */
diff --git a/libnm/nm-device-wifi.h b/libnm/nm-device-wifi.h
index 9885438f02..8448acfea7 100644
--- a/libnm/nm-device-wifi.h
+++ b/libnm/nm-device-wifi.h
@@ -78,8 +78,8 @@ NMAccessPoint * nm_device_wifi_get_access_point_by_path (NMDeviceWifi *
const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi *device);
-NM_AVAILABLE_IN_1_2
-gint nm_device_wifi_get_last_scan (NMDeviceWifi *device);
+NM_AVAILABLE_IN_1_12
+gint64 nm_device_wifi_get_last_scan (NMDeviceWifi *device);
gboolean nm_device_wifi_request_scan (NMDeviceWifi *device,
GCancellable *cancellable,
diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h
index 4b081630cf..588552375e 100644
--- a/shared/nm-utils/nm-shared-utils.h
+++ b/shared/nm-utils/nm-shared-utils.h
@@ -520,8 +520,9 @@ void _nm_utils_strv_sort (const char **strv, gssize len);
/*****************************************************************************/
-#define NM_UTILS_NS_PER_SECOND ((gint64) 1000000000)
-#define NM_UTILS_NS_PER_MSEC ((gint64) 1000000)
+#define NM_UTILS_NS_PER_SECOND ((gint64) 1000000000)
+#define NM_UTILS_NS_PER_MSEC ((gint64) 1000000)
+#define NM_UTILS_MSEC_PER_SECOND ((gint64) 1000)
#define NM_UTILS_NS_TO_MSEC_CEIL(nsec) (((nsec) + (NM_UTILS_NS_PER_MSEC - 1)) / NM_UTILS_NS_PER_MSEC)
/*****************************************************************************/
diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c
index 58bafb81d4..d28fcdbdc7 100644
--- a/src/devices/wifi/nm-device-iwd.c
+++ b/src/devices/wifi/nm-device-iwd.c
@@ -80,7 +80,7 @@ typedef struct {
bool can_connect:1;
bool scanning:1;
bool scan_requested:1;
- gint32 last_scan;
+ gint64 last_scan;
} NMDeviceIwdPrivate;
struct _NMDeviceIwd {
@@ -865,7 +865,7 @@ scan_cb (GObject *source, GAsyncResult *res, gpointer user_data)
priv = NM_DEVICE_IWD_GET_PRIVATE (self);
priv->scan_requested = FALSE;
- priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
+ priv->last_scan = nm_utils_get_monotonic_timestamp_ms ();
_notify (self, PROP_LAST_SCAN);
/* On success, priv->scanning becomes true right before or right
@@ -1535,10 +1535,10 @@ get_property (GObject *object, guint prop_id,
g_value_set_boolean (value, priv->scanning);
break;
case PROP_LAST_SCAN:
- g_value_set_int (value,
- priv->last_scan > 0
- ? (gint) nm_utils_monotonic_timestamp_as_boottime (priv->last_scan, NM_UTILS_NS_PER_SECOND)
- : -1);
+ g_value_set_int64 (value,
+ priv->last_scan > 0
+ ? nm_utils_monotonic_timestamp_as_boottime (priv->last_scan, NM_UTILS_NS_PER_MSEC)
+ : (gint64) -1);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1920,9 +1920,9 @@ nm_device_iwd_class_init (NMDeviceIwdClass *klass)
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_LAST_SCAN] =
- g_param_spec_int (NM_DEVICE_IWD_LAST_SCAN, "", "",
- -1, G_MAXINT, -1,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_param_spec_int64 (NM_DEVICE_IWD_LAST_SCAN, "", "",
+ -1, G_MAXINT64, -1,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index bcb0e5471f..1a86e13bf6 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -97,8 +97,8 @@ typedef struct {
bool ssid_found:1;
bool is_scanning:1;
- gint32 last_scan;
- gint32 scheduled_scan_time;
+ gint64 last_scan; /* milliseconds */
+ gint32 scheduled_scan_time; /* seconds */
guint8 scan_interval; /* seconds */
guint pending_scan_id;
guint ap_dump_id;
@@ -1127,7 +1127,7 @@ _nm_device_wifi_request_scan (NMDeviceWifi *self,
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMDevice *device = NM_DEVICE (self);
- gint32 last_scan;
+ gint64 last_scan;
if ( !priv->enabled
|| !priv->sup_iface
@@ -1148,8 +1148,8 @@ _nm_device_wifi_request_scan (NMDeviceWifi *self,
return;
}
- last_scan = nm_supplicant_interface_get_last_scan_time (priv->sup_iface);
- if (last_scan && (nm_utils_get_monotonic_timestamp_s () - last_scan) < 10) {
+ last_scan = nm_supplicant_interface_get_last_scan (priv->sup_iface);
+ if (last_scan && (nm_utils_get_monotonic_timestamp_ms () - last_scan) < 10 * NM_UTILS_MSEC_PER_SECOND) {
g_dbus_method_invocation_return_error_literal (invocation,
NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ALLOWED,
@@ -1423,7 +1423,7 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface,
_LOGD (LOGD_WIFI, "wifi-scan: scan-done callback: %s", success ? "successful" : "failed");
- priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
+ priv->last_scan = nm_utils_get_monotonic_timestamp_ms ();
_notify (self, PROP_LAST_SCAN);
schedule_scan (self, success);
@@ -1447,9 +1447,9 @@ ap_list_dump (gpointer user_data)
NMWifiAP *ap;
gint32 now_s = nm_utils_get_monotonic_timestamp_s ();
- _LOGD (LOGD_WIFI_SCAN, "APs: [now:%u last:%u next:%u]",
+ _LOGD (LOGD_WIFI_SCAN, "APs: [now:%u last:%" G_GINT64_FORMAT " next:%u]",
now_s,
- priv->last_scan,
+ priv->last_scan / NM_UTILS_MSEC_PER_SECOND,
priv->scheduled_scan_time);
c_list_for_each_entry (ap, &priv->aps_lst_head, aps_lst)
_ap_dump (self, LOGL_DEBUG, ap, "dump", now_s);
@@ -3185,10 +3185,10 @@ get_property (GObject *object, guint prop_id,
g_value_set_boolean (value, priv->is_scanning);
break;
case PROP_LAST_SCAN:
- g_value_set_int (value,
- priv->last_scan > 0
- ? (gint) nm_utils_monotonic_timestamp_as_boottime (priv->last_scan, NM_UTILS_NS_PER_SECOND)
- : -1);
+ g_value_set_int64 (value,
+ priv->last_scan > 0
+ ? nm_utils_monotonic_timestamp_as_boottime (priv->last_scan, NM_UTILS_NS_PER_MSEC)
+ : (gint64) -1);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -3369,9 +3369,9 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_LAST_SCAN] =
- g_param_spec_int (NM_DEVICE_WIFI_LAST_SCAN, "", "",
- -1, G_MAXINT, -1,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_param_spec_int64 (NM_DEVICE_WIFI_LAST_SCAN, "", "",
+ -1, G_MAXINT64, -1,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
diff --git a/src/devices/wifi/nm-wifi-common.c b/src/devices/wifi/nm-wifi-common.c
index 0030b32dff..8e079d1151 100644
--- a/src/devices/wifi/nm-wifi-common.c
+++ b/src/devices/wifi/nm-wifi-common.c
@@ -200,7 +200,7 @@ const NMDBusInterfaceInfoExtended nm_interface_info_device_wireless = {
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("AccessPoints", "ao", NM_DEVICE_WIFI_ACCESS_POINTS),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ActiveAccessPoint", "o", NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("WirelessCapabilities", "u", NM_DEVICE_WIFI_CAPABILITIES),
- NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("LastScan", "i", NM_DEVICE_WIFI_LAST_SCAN),
+ NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("LastScan", "x", NM_DEVICE_WIFI_LAST_SCAN),
),
),
.legacy_property_changed = TRUE,
diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c
index 3511b151e4..71e6a35ac5 100644
--- a/src/supplicant/nm-supplicant-interface.c
+++ b/src/supplicant/nm-supplicant-interface.c
@@ -129,7 +129,7 @@ typedef struct {
GHashTable * bss_proxies;
char * current_bss;
- gint32 last_scan; /* timestamp as returned by nm_utils_get_monotonic_timestamp_s() */
+ gint64 last_scan; /* timestamp as returned by nm_utils_get_monotonic_timestamp_ms() */
} NMSupplicantInterfacePrivate;
@@ -209,7 +209,7 @@ bss_proxy_properties_changed_cb (GDBusProxy *proxy,
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
if (priv->scanning)
- priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
+ priv->last_scan = nm_utils_get_monotonic_timestamp_ms ();
g_signal_emit (self, signals[BSS_UPDATED], 0,
g_dbus_proxy_get_object_path (proxy),
@@ -344,7 +344,7 @@ set_state (NMSupplicantInterface *self, NMSupplicantInterfaceState new_state)
if ( priv->state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING
|| old_state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING)
- priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
+ priv->last_scan = nm_utils_get_monotonic_timestamp_ms ();
/* Disconnect reason is no longer relevant when not in the DISCONNECTED state */
if (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED)
@@ -406,7 +406,7 @@ set_scanning (NMSupplicantInterface *self, gboolean new_scanning)
/* Cache time of last scan completion */
if (priv->scanning == FALSE)
- priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
+ priv->last_scan = nm_utils_get_monotonic_timestamp_ms ();
_notify (self, PROP_SCANNING);
}
@@ -438,8 +438,8 @@ nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self)
return priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY ? priv->current_bss : NULL;
}
-gint32
-nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self)
+gint64
+nm_supplicant_interface_get_last_scan (NMSupplicantInterface *self)
{
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->last_scan;
}
@@ -987,7 +987,7 @@ wpas_iface_scan_done (GDBusProxy *proxy,
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
/* Cache last scan completed time */
- priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
+ priv->last_scan = nm_utils_get_monotonic_timestamp_ms ();
priv->scan_done_success |= success;
scan_done_emit_signal (self);
}
@@ -1002,7 +1002,7 @@ wpas_iface_bss_added (GDBusProxy *proxy,
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
if (priv->scanning)
- priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
+ priv->last_scan = nm_utils_get_monotonic_timestamp_ms ();
bss_add_new (self, path);
}
diff --git a/src/supplicant/nm-supplicant-interface.h b/src/supplicant/nm-supplicant-interface.h
index f32ad8dda2..31272b3c11 100644
--- a/src/supplicant/nm-supplicant-interface.h
+++ b/src/supplicant/nm-supplicant-interface.h
@@ -110,7 +110,7 @@ gboolean nm_supplicant_interface_get_scanning (NMSupplicantInterface *self);
const char *nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self);
-gint32 nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self);
+gint64 nm_supplicant_interface_get_last_scan (NMSupplicantInterface *self);
const char *nm_supplicant_interface_get_ifname (NMSupplicantInterface *self);
diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py
index e866e0a617..65f168cb21 100755
--- a/tools/test-networkmanager-service.py
+++ b/tools/test-networkmanager-service.py
@@ -924,7 +924,7 @@ class WifiDevice(Device):
PRP_WIFI_WIRELESS_CAPABILITIES: dbus.UInt32(0xFF),
PRP_WIFI_ACCESS_POINTS: ExportedObj.to_path_array(self.aps),
PRP_WIFI_ACTIVE_ACCESS_POINT: ExportedObj.to_path(None),
- PRP_WIFI_LAST_SCAN: dbus.Int32(0x70000000),
+ PRP_WIFI_LAST_SCAN: dbus.Int64(0x7000000000000000),
}
self.dbus_interface_add(IFACE_WIFI, props, WifiDevice.PropertiesChanged)