This has been bugging me for ages but I forgot about it for quite a
while (mostly because iwn scanning was broken on my laptop for ages).
RSSI is a signed value, but various places are storing it unsigned,
in particular ifconfig prints it that way (so the displayed strength
is unfeasibly large; realistic values are maybe -40 [very strong
signal] to -90 or so).

Diff below fixes things for ifconfig and doesn't affect things used
in other places in the kernel. Sample output from iwn scan below (and
the values are sensible).

OK?

                nwid Y2 chan 104 bssid 04:4f:f5:0c:a7:ec -52dB 54M 
privacy,spectrum_mgmt,short_slottime,wpa2 
                nwid Y2-x chan 5 bssid 04:4f:f5:4c:a7:e8 -53dB 54M 
privacy,short_preamble,short_slottime,wpa2,802.1x 
                nwid BTHub3-MM9S chan 6 bssid 00:81:d8:1a:c5:22 -78dB 54M 
privacy,short_preamble,short_slottime,wpa2 
                nwid BTHub3-C2KT chan 11 bssid 40:4d:8e:51:3f:b9 -83dB 54M 
privacy,short_slottime,wpa2 
                nwid Laboratory chan 2 bssid 78:54:2e:8a:c9:7a -89dB 54M 
privacy,short_slottime,wpa2 

There are various other rssi values (variables and returned by
functions) which also use u_int8_t - ni_rssi, ic_max_rssi,
ic_node_getrssi(), and some in rateadapt - as well as rxi_rssi which
was already signed (and is copied to various unsigned variables).
These seem more risky to change (or at least more complicated)
so I haven't touched them here, but I wonder, does anyone have a
handle on what's going on with these?

Index: sys/net80211/ieee80211_ioctl.h
===================================================================
RCS file: /cvs/src/sys/net80211/ieee80211_ioctl.h,v
retrieving revision 1.20
diff -u -p -r1.20 ieee80211_ioctl.h
--- sys/net80211/ieee80211_ioctl.h      24 Aug 2014 18:01:27 -0000      1.20
+++ sys/net80211/ieee80211_ioctl.h      9 Jan 2015 15:27:10 -0000
@@ -295,8 +295,8 @@ struct ieee80211_nodereq {
        u_int8_t        nr_rates[IEEE80211_RATE_MAXSIZE];       /* rate set */
 
        /* Node status information */
-       u_int8_t        nr_rssi;        /* received signal strength */
-       u_int8_t        nr_max_rssi;    /* maximum rssi */
+       int8_t          nr_rssi;        /* received signal strength */
+       int8_t          nr_max_rssi;    /* maximum rssi */
        u_int8_t        nr_tstamp[8];   /* from last received beacon */
        u_int16_t       nr_intval;      /* beacon interval */
        u_int16_t       nr_capinfo;     /* capabilities */
Index: sbin/ifconfig/ifconfig.c
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.293
diff -u -p -r1.293 ifconfig.c
--- sbin/ifconfig/ifconfig.c    6 Jan 2015 21:26:46 -0000       1.293
+++ sbin/ifconfig/ifconfig.c    9 Jan 2015 15:27:10 -0000
@@ -2087,7 +2087,7 @@ ieee80211_status(void)
                        if (nr.nr_max_rssi)
                                printf(" %u%%", IEEE80211_NODEREQ_RSSI(&nr));
                        else
-                               printf(" %udB", nr.nr_rssi);
+                               printf(" %ddB", nr.nr_rssi);
                }
        }
 
@@ -2318,7 +2318,7 @@ ieee80211_printnode(struct ieee80211_nod
        if (nr->nr_max_rssi)
                printf("%u%% ", IEEE80211_NODEREQ_RSSI(nr));
        else
-               printf("%udB ", nr->nr_rssi);
+               printf("%ddB ", nr->nr_rssi);
 
        if (nr->nr_pwrsave)
                printf("powersave ");

Reply via email to