From c45bc61644eedd398fea413ee86ef28df94ac552 Mon Sep 17 00:00:00 2001
From: Janusz Dziedzic <janusz.dziedzic@iopsys.eu>
Date: Thu, 9 Dec 2021 11:32:44 +0100
Subject: [PATCH] ubus status display macaddr/bssid correctly

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@iopsys.eu>
---
 src/cntlr_ubus.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/cntlr_ubus.c b/src/cntlr_ubus.c
index 01517939..e28030c8 100644
--- a/src/cntlr_ubus.c
+++ b/src/cntlr_ubus.c
@@ -440,13 +440,14 @@ static int cntlr_status(struct ubus_context *ctx, struct ubus_object *obj,
 
 		b = blobmsg_open_array(&bb, "radios");
 		list_for_each_entry(p, &n->radiolist, list) {
+			char macaddrstr[18] = {0};
 			char bssidstr[18] = {0};
 			void *tttt, *ttttt;
 			struct netif_iface *fh;
 
-			hwaddr_ntoa(p->macaddr, bssidstr);
+			hwaddr_ntoa(p->macaddr, macaddrstr);
 			tt = blobmsg_open_table(&bb, "");
-			blobmsg_add_string(&bb, "bssid", bssidstr);
+			blobmsg_add_string(&bb, "macaddr", macaddrstr);
 
 			/* Show current/prefered opclasses */
 			cntlr_status_add_opclass(&bb, &p->cur_opclass, "cur_opclass", 20);
@@ -467,20 +468,22 @@ static int cntlr_status(struct ubus_context *ctx, struct ubus_object *obj,
 				memset(bssidstr, 0, sizeof(bssidstr));
 				hwaddr_ntoa(fh->bssid, bssidstr);
 				ttttt = blobmsg_open_table(&bb, "");
-				blobmsg_add_string(&bb, "bssid", bssidstr);
 				if (fh->type == NETIF_FHBSS) {
+					blobmsg_add_string(&bb, "bssid", bssidstr);
 					strcpy(type, "fronthaul");
 					blobmsg_add_string(&bb, "ssid", fh->ssid);
 				} else if (fh->type == NETIF_BKBSS) {
+					blobmsg_add_string(&bb, "bssid", bssidstr);
 					strcpy(type, "backhaul");
 					blobmsg_add_string(&bb, "ssid", fh->ssid);
 				} else if (fh->type == NETIF_BSTA) {
+					blobmsg_add_string(&bb, "macaddr", bssidstr);
 					strcpy(type, "station");
 				}
 				blobmsg_add_string(&bb, "type", type);
 				if (!hwaddr_is_zero(fh->upstream_bssid)) {
 					hwaddr_ntoa(fh->upstream_bssid, bssidstr);
-					blobmsg_add_string(&bb, "upstream", bssidstr);
+					blobmsg_add_string(&bb, "bssid", bssidstr);
 				}
 
 				blobmsg_close_table(&bb, ttttt);
-- 
GitLab