[LEDE-DEV] [PATCH rpcd] iwinfo: add info about frequency restrictions

Rafał Miłecki zajec5 at gmail.com
Tue Aug 15 03:49:33 PDT 2017


From: Rafał Miłecki <rafal at milecki.pl>

Example frequency:
{
	"channel": 1,
	"mhz": 2412,
	"restricted": false,
	"active": false,
	"restrictions": {
		"no_ht40minus": true,
		"no_80mhz": true
	}
}

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 iwinfo.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/iwinfo.c b/iwinfo.c
index 1849196..3f18ae2 100644
--- a/iwinfo.c
+++ b/iwinfo.c
@@ -503,7 +503,7 @@ rpc_iwinfo_freqlist(struct ubus_context *ctx, struct ubus_object *obj,
 	int i, rv, len, ch;
 	char res[IWINFO_BUFSIZE];
 	struct iwinfo_freqlist_entry *f;
-	void *c, *d;
+	void *c, *d, *e;
 
 	rv = rpc_iwinfo_open(msg);
 
@@ -531,6 +531,21 @@ rpc_iwinfo_freqlist(struct ubus_context *ctx, struct ubus_object *obj,
 			if (ch > -1)
 				blobmsg_add_u8(&buf, "active", f->channel == ch);
 
+			e = blobmsg_open_table(&buf, "restrictions");
+			if (f->flags & IWINFO_FREQ_NO_10MHZ)
+				blobmsg_add_u8(&buf, "no_10mhz", 1);
+			if (f->flags & IWINFO_FREQ_NO_20MHZ)
+				blobmsg_add_u8(&buf, "no_20mhz", 1);
+			if (f->flags & IWINFO_FREQ_NO_HT40PLUS)
+				blobmsg_add_u8(&buf, "no_ht40plus", 1);
+			if (f->flags & IWINFO_FREQ_NO_HT40MINUS)
+				blobmsg_add_u8(&buf, "no_ht40minus", 1);
+			if (f->flags & IWINFO_FREQ_NO_80MHZ)
+				blobmsg_add_u8(&buf, "no_80mhz", 1);
+			if (f->flags & IWINFO_FREQ_NO_160MHZ)
+				blobmsg_add_u8(&buf, "no_160mhz", 1);
+			blobmsg_close_table(&buf, e);
+
 			blobmsg_close_table(&buf, d);
 		}
 	}
-- 
2.11.0




More information about the Lede-dev mailing list