]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: channels: show CAC ongoing time main master
authorJanusz Dziedzic <janusz.dziedzic@gmail.com>
Wed, 6 May 2026 15:41:03 +0000 (17:41 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 20 May 2026 10:06:19 +0000 (12:06 +0200)
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
Link: https://patch.msgid.link/20260506154103.199563-1-janusz.dziedzic@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
phy.c

diff --git a/phy.c b/phy.c
index 03a782220b66a70bf458e61a6b4cc1f1f1ad84b9..ab629c6b4eb32497eb02aa6977a6caf8d44937fe 100644 (file)
--- a/phy.c
+++ b/phy.c
@@ -5,6 +5,7 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <time.h>
 
 #include <netlink/genl/genl.h>
 #include <netlink/genl/family.h>
@@ -143,6 +144,20 @@ static int print_channels_handler(struct nl_msg *msg, void *arg)
                                                        printf("\t  DFS CAC time: %u ms\n",
                                                               nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME]));
                                        }
+
+                                       if (tb_freq[NL80211_FREQUENCY_ATTR_CAC_START_TIME]) {
+                                               struct timespec now_ts;
+                                               unsigned long long now_ns, cac_start_ns, elapsed_ms;
+
+                                               clock_gettime(CLOCK_BOOTTIME, &now_ts);
+                                               now_ns = now_ts.tv_sec * 1000000000ULL;
+                                               now_ns += now_ts.tv_nsec;
+
+                                               cac_start_ns = nla_get_u64(tb_freq[NL80211_FREQUENCY_ATTR_CAC_START_TIME]);
+                                               elapsed_ms = (now_ns - cac_start_ns) / 1000000;
+
+                                               printf("\t  CAC ongoing (elapsed time: %llu ms)\n", elapsed_ms);
+                                       }
                                }
                        }
                }