[package] iwinfo: fix logic flaw in WPA OUI filtering, solves misdetecting various...
[openwrt.git] / package / iwinfo / src / iwinfo_cli.c
index bfa1d88..d60d7b8 100644 (file)
@@ -311,6 +311,36 @@ static char * print_hardware_name(const struct iwinfo_ops *iw, const char *ifnam
        return buf;
 }
 
+static char * print_txpower_offset(const struct iwinfo_ops *iw, const char *ifname)
+{
+       int off;
+       static char buf[12];
+
+       if (iw->txpower_offset(ifname, &off))
+               snprintf(buf, sizeof(buf), "unknown");
+       else if (off != 0)
+               snprintf(buf, sizeof(buf), "%d dB", off);
+       else
+               snprintf(buf, sizeof(buf), "none");
+
+       return buf;
+}
+
+static char * print_frequency_offset(const struct iwinfo_ops *iw, const char *ifname)
+{
+       int off;
+       static char buf[12];
+
+       if (iw->frequency_offset(ifname, &off))
+               snprintf(buf, sizeof(buf), "unknown");
+       else if (off != 0)
+               snprintf(buf, sizeof(buf), "%.3f GHz", ((float)off / 1000.0));
+       else
+               snprintf(buf, sizeof(buf), "none");
+
+       return buf;
+}
+
 static char * print_ssid(const struct iwinfo_ops *iw, const char *ifname)
 {
        char buf[IWINFO_ESSID_MAX_SIZE+1] = { 0 };
@@ -361,9 +391,14 @@ static char * print_frequency(const struct iwinfo_ops *iw, const char *ifname)
 
 static char * print_txpower(const struct iwinfo_ops *iw, const char *ifname)
 {
-       int pwr;
+       int pwr, off;
+       if (iw->txpower_offset(ifname, &off))
+               off = 0;
+
        if (iw->txpower(ifname, &pwr))
                pwr = -1;
+       else
+               pwr += off;
 
        return format_txpower(pwr);
 }
@@ -473,6 +508,10 @@ static void print_info(const struct iwinfo_ops *iw, const char *ifname)
        printf("          Hardware: %s [%s]\n",
                print_hardware_id(iw, ifname),
                print_hardware_name(iw, ifname));
+       printf("          TX power offset: %s\n",
+               print_txpower_offset(iw, ifname));
+       printf("          Frequency offset: %s\n",
+               print_frequency_offset(iw, ifname));
        printf("          Supports VAPs: %s\n",
                print_mbssid_supp(iw, ifname));
 }
@@ -519,7 +558,7 @@ static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname)
 
 static void print_txpwrlist(const struct iwinfo_ops *iw, const char *ifname)
 {
-       int len, pwr, i;
+       int len, pwr, off, i;
        char buf[IWINFO_BUFSIZE];
        struct iwinfo_txpwrlist_entry *e;
 
@@ -532,14 +571,17 @@ static void print_txpwrlist(const struct iwinfo_ops *iw, const char *ifname)
        if (iw->txpower(ifname, &pwr))
                pwr = -1;
 
+       if (iw->txpower_offset(ifname, &off))
+               off = 0;
+
        for (i = 0; i < len; i += sizeof(struct iwinfo_txpwrlist_entry))
        {
                e = (struct iwinfo_txpwrlist_entry *) &buf[i];
 
                printf("%s%3d dBm (%4d mW)\n",
                        (pwr == e->dbm) ? "*" : " ",
-                       e->dbm,
-                       e->mw);
+                       e->dbm + off,
+                       iwinfo_dbm2mw(e->dbm + off));
        }
 }
 
This page took 0.024796 seconds and 4 git commands to generate.