iwinfo: add "band" to the freqlist output
authorAndre Heider <a.heider@gmail.com>
Tue, 22 Nov 2022 10:41:13 +0000 (11:41 +0100)
committerChristian 'Ansuel' Marangi <ansuelsmth@gmail.com>
Sat, 21 Jan 2023 00:18:11 +0000 (01:18 +0100)
So that consumers don't have to fiddle around with mapping frequencies
to bands, which everyone seems to do a little differently.

Signed-off-by: Andre Heider <a.heider@gmail.com>
iwinfo.c

index e088ea68430738504a54fbc66f126180fabe3ae8..904b268394e742faec8be0f48e3bb316ab5c0aa9 100644 (file)
--- a/iwinfo.c
+++ b/iwinfo.c
@@ -607,7 +607,7 @@ rpc_iwinfo_freqlist(struct ubus_context *ctx, struct ubus_object *obj,
                     struct ubus_request_data *req, const char *method,
                     struct blob_attr *msg)
 {
-       int i, rv, len, ch;
+       int i, rv, len, ch, band;
        char res[IWINFO_BUFSIZE];
        struct iwinfo_freqlist_entry *f;
        void *c, *d;
@@ -631,6 +631,9 @@ rpc_iwinfo_freqlist(struct ubus_context *ctx, struct ubus_object *obj,
                        f = (struct iwinfo_freqlist_entry *)&res[i];
                        d = blobmsg_open_table(&buf, NULL);
 
+                       band = iwinfo_band2ghz(f->band);
+                       if (band > 0)
+                               blobmsg_add_u32(&buf, "band", band);
                        blobmsg_add_u32(&buf, "channel", f->channel);
                        blobmsg_add_u32(&buf, "mhz", f->mhz);
                        blobmsg_add_u8(&buf, "restricted", f->restricted);