session: Fix crash when the UCI option 'password' or 'username' is missing
[project/rpcd.git] / iwinfo.c
index cdbb8706f34eb8488e965966fc8742c3217f2e6d..f8dec8005889f4f3ac9394c0f9802b78de6b4bb0 100644 (file)
--- a/iwinfo.c
+++ b/iwinfo.c
@@ -258,10 +258,14 @@ rpc_iwinfo_call_hwmodes(const char *name)
 
 static void rpc_iwinfo_call_hw_ht_mode(int hwmodelist)
 {
+       char text[32];
        const char *hwmode_str;
        const char *htmode_str;
        int htmode;
 
+       if (iwinfo_format_hwmodes(hwmodelist, text, sizeof(text)) > 0)
+               blobmsg_add_string(&buf, "hwmodes_text", text);
+
        if (hwmodelist == IWINFO_80211_AD)
        {
                blobmsg_add_string(&buf, "hwmode", "ad");
@@ -362,7 +366,7 @@ rpc_iwinfo_scan(struct ubus_context *ctx, struct ubus_object *obj,
                 struct ubus_request_data *req, const char *method,
                 struct blob_attr *msg)
 {
-       int i, rv, len;
+       int i, rv, len, band;
        void *c, *d, *t;
        char mac[18];
        char res[IWINFO_BUFSIZE];
@@ -395,7 +399,11 @@ rpc_iwinfo_scan(struct ubus_context *ctx, struct ubus_object *obj,
 
                        blobmsg_add_string(&buf, "mode", IWINFO_OPMODE_NAMES[e->mode]);
 
+                       band = iwinfo_band2ghz(e->band);
+                       if (band > 0)
+                               blobmsg_add_u32(&buf, "band", band);
                        blobmsg_add_u32(&buf, "channel", e->channel);
+                       blobmsg_add_u32(&buf, "mhz", e->mhz);
                        blobmsg_add_u32(&buf, "signal", (uint32_t)(e->signal - 0x100));
 
                        blobmsg_add_u32(&buf, "quality", e->quality);
@@ -527,7 +535,7 @@ rpc_iwinfo_assoclist(struct ubus_context *ctx, struct ubus_object *obj,
                        e = blobmsg_open_table(&buf, "rx");
                        blobmsg_add_u64(&buf, "drop_misc", a->rx_drop_misc);
                        blobmsg_add_u32(&buf, "packets", a->rx_packets);
-                       blobmsg_add_u32(&buf, "bytes", a->rx_bytes);
+                       blobmsg_add_u64(&buf, "bytes", a->rx_bytes);
                        rpc_iwinfo_add_rateinfo(&a->rx_rate);
                        blobmsg_close_table(&buf, e);
 
@@ -535,7 +543,7 @@ rpc_iwinfo_assoclist(struct ubus_context *ctx, struct ubus_object *obj,
                        blobmsg_add_u32(&buf, "failed", a->tx_failed);
                        blobmsg_add_u32(&buf, "retries", a->tx_retries);
                        blobmsg_add_u32(&buf, "packets", a->tx_packets);
-                       blobmsg_add_u32(&buf, "bytes", a->tx_bytes);
+                       blobmsg_add_u64(&buf, "bytes", a->tx_bytes);
                        rpc_iwinfo_add_rateinfo(&a->tx_rate);
                        blobmsg_close_table(&buf, e);
 
@@ -603,7 +611,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;
@@ -627,10 +635,18 @@ 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);
 
+                       rpc_iwinfo_add_bit_array("flags", f->flags,
+                                               IWINFO_FREQ_FLAG_NAMES,
+                                               IWINFO_FREQ_FLAG_COUNT,
+                                               true, 0);
+
                        if (ch > -1)
                                blobmsg_add_u8(&buf, "active", f->channel == ch);