From 6dc51ddf01afe790bcf48d93192a0e535987334e Mon Sep 17 00:00:00 2001 From: Jan Fooken Date: Tue, 4 Nov 2025 09:35:27 +0100 Subject: [PATCH] device: add public method nm_device_auth_retries_has_next Devices don't know whether they have authentication retries left, so they can only make decisions ad-hoc after calling nm_device_auth_retries_try_next. Giving devices a way to determine whether the current attempt is their last attempt, allows them to make decisions before failing a connection. --- src/core/devices/nm-device.c | 18 ++++++++++++++++++ src/core/devices/nm-device.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 03343f3fef..a00f04b579 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -18947,6 +18947,24 @@ _device_get_auth_retries(NMDevice *self) return auth_retries; } +gboolean +nm_device_auth_retries_has_next(NMDevice *self) +{ + int auth_retries; + + g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); + + auth_retries = _device_get_auth_retries(self); + + if (auth_retries == NM_DEVICE_AUTH_RETRIES_INFINITY) + return TRUE; + + if (auth_retries > 0) + return TRUE; + + return FALSE; +} + gboolean nm_device_auth_retries_try_next(NMDevice *self) { diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 2f287953eb..c8069d7c1d 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -791,6 +791,7 @@ void nm_device_update_permanent_hw_address(NMDevice *self, gboolean force_fr void nm_device_update_dynamic_ip_setup(NMDevice *self, const char *reason); guint nm_device_get_supplicant_timeout(NMDevice *self); +gboolean nm_device_auth_retries_has_next(NMDevice *self); gboolean nm_device_auth_retries_try_next(NMDevice *self); gboolean nm_device_hw_addr_get_cloned(NMDevice *self,