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

Message ID 20170815104933.16705-1-zajec5@gmail.com
State New
Delegated to: Rafał Miłecki
Headers show

Commit Message

Rafał Miłecki Aug. 15, 2017, 10:49 a.m.
From: Rafał Miłecki <rafal@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@milecki.pl>
---
 iwinfo.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Patch

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);
 		}
 	}