From 8704a0bd32b3005f73df6a1fdeb297f3eb56baa6 Mon Sep 17 00:00:00 2001
From: Janusz Dziedzic <janusz.dziedzic@iopsys.eu>
Date: Tue, 25 Feb 2025 17:02:33 +0100
Subject: [PATCH] apmld stats

---
 wifimngr.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/wifimngr.c b/wifimngr.c
index 277b4de..db03820 100644
--- a/wifimngr.c
+++ b/wifimngr.c
@@ -5306,7 +5306,23 @@ int wl_apmld_stats(struct ubus_context *ctx, struct ubus_object *obj,
 		   struct ubus_request_data *req, const char *method,
 		   struct blob_attr *msg)
 {
-	return 0;
+	struct wifi_ap_stats ifstats = {};
+	struct blob_buf bb = {};
+	const char *ifname;
+	void *t;
+
+	ifname = ubus_objname_to_ifname(obj);
+	wifi_ap_get_stats(ifname, &ifstats);
+
+	blob_buf_init(&bb, 0);
+	t = blobmsg_open_table(&bb, "stats");
+	print_apstats(&bb, &ifstats);
+	blobmsg_close_table(&bb, t);
+
+	ubus_send_reply(ctx, req, bb.head);
+	blob_buf_free(&bb);
+
+	return UBUS_STATUS_OK;
 }
 
 int wl_apmld_assoclist(struct ubus_context *ctx, struct ubus_object *obj,
-- 
GitLab